DEV Community

Discussion on: Axios Async/Await with Retry

Collapse
 
neerajkumargupta profile image
neerajkumargupta

Hi, this is not working for me. I tried and it only prints for first retry and after that comes out of the condition

Collapse
 
yogski profile image
Yogi Saputro

Hi, thanks for visiting.
Could you share your code and API you are trying to hit, please? This post primarily deal with retry mechanism. In your case, I guess it is about handling the response.

In this case, response of 400 and 500 will cause it to try again. You could check the response, if the response is 200, then there's no need to retry. Your request is success.

However, some API give 200 status for failed request. So you need to handle it manually.