DEV Community

Discussion on: Axios Async/Await with Retry

Collapse
 
yogski profile image
Yogi Saputro

You can wrap the POST request as usual, then adjust the timeout accordingly. If the network is unstable, set timeout to 3 seconds (3000 in code) and set retry to 3-5 times. If login is successful, user will be redirected immediately. If it failed, throw notification that login failed due to network issue, and user can try to log in again.

Be warned that it has trade-off of higher traffic for server.
Find the best configuration between timeout and retries that suit your needs.