losing internet connection while sending multiple API calls one by one

Viewed 150

I want to make multiple API calls one by one and the second one will be dependent on the result of the first one. What if I lost my internet connection in between each call?

Example:

const test1 = async () => {

  const var1 = await function1()

  // loss of internet connection or browser gets shut down

  const var2 = await function2(var1)

}


Will var2 get executed or will it have expected result returned to me? If not, what are the workarounds to make sure two calls get executed?

1 Answers

If you try to call api without connection, you get an error. In your case error will be thrown when you call await someApiCall(). Workaround is to put some kind of retry logic.

Related