Just a little tip if you don't know this already - check that the charge port (assuming it's a USB-C) doesn't just need a good clean.
I get this every so often, when any cable I plug in doesn't make a good connection, so charging keeps dropping out. It turns out that the port can get easily blocked up with fluff and dust from your pockets. It gets compacted as you use the port, which stops the connector seating properly, but also means you can't clean it with just compressed air.
Get something like a sewing needle (thick enough to use without bending, but thin enough to fit between the outside edge of the socket and the connector in the middle) and scrape around in there - you'll probably be surprised at the amount of muck which comes out. You might find this helps immensely - you'll because when you next plug something in, you'll feel it 'click' home more securely.