The problem about API retry requests

The problem about API retry requests
Probably you were doing this mistake in your backend.
So you have your web app whatsoever that makes requests to your backend. When things go wrong and there are network connection problems, there are two possibles scenarios.
First scenario, it's where your requests might not arrive to the backend and get lost in the middle of the way:

The second one, they might arrive, but is the response of the backend what get lost:

How do you differentiate these two scenario? Your web app will not know, and you might be asking yourself if you should even care about this. You can always try again and that's it.
Surely, if your requests are GET requests there is no problem at all, you are just fetching data. However, the problem lies with mutation requests, where you alter the state of the system. So if you have a POST request and you send twice by mistake, that can have big consequences in the system.
How do we solve this? You generate IDs for your mutation requests that are sensible to this problem and then send the requests with that ID.
Now the backend receives a POST with an ID, if it's the first time it sees that ID, then executes the mutation, returns the response and store the ID and response for a period of time.
If the POST request with the same ID arrives again, you just return the cached response.
Easy peasy, right?