I'm new to react native and notice the similarity with Javascript, event loop, async.
My app functionality is divided into 5 pages. One is home page, clicking on button takes to page 1. Page 1 has button, clicking on it takes user to page 2, and similarly for page 2 to page 3 and page 4 to page 5.
At each button click I am making a http POST request that uploads a text file. Fetch is inherently async so it happens in the background. This may pass or fail. If it does pass I want to record the status as pass. And if it fails then I want to record the status as failed and reattempt the upload, all this should happen without blocking the user from going into subsequent pages.
I am looking for a high level architecture to understand how to track async http calls via react native and retry failed request?
First thing to say is, it really depends on your backend design whether the fetch really is async or not.
Eventually what holds true is, that you will have a delay for any answer, which is probably why you say it is inherently async?
Normally you can use async functions and await the answers in javascript and react or use a .then chain to wait for the resolution of your request. With that your user has to wait a second, but you can either in the background or visible for the user register the result.
If you want to use retry logic I recommend to take a look at axios and axios interceptors. With that you can check for certain error codes in the API response and call with the same request again or change the request if needed.