Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to check response of last retry? #233

Open
artgoce opened this issue Jul 20, 2023 · 1 comment
Open

Is there any way to check response of last retry? #233

artgoce opened this issue Jul 20, 2023 · 1 comment

Comments

@artgoce
Copy link

artgoce commented Jul 20, 2023

I wonder if there is any way to check the response of the last retry, because using an axios error interceptor gets executed at every retry.

@yutak23
Copy link
Contributor

yutak23 commented Aug 2, 2023

the response of the last retry

After the maximum retries are reached, the error is not retried and the error is reject.
Therefore, the response at the last retry can be seen in the catch block of the following example.

https://github.com/softonic/axios-retry/blob/master/es/index.mjs#L254C12-L254C34

import axios from 'axios';
import axiosRetry from 'axios-retry';

axiosRetry(axios);

try { 
  axios.get(...); // for example, if a 500 error occurs, the default is 3 retries, and if it is still an error, the process moves to the catch block.
} catch (e) {
   console.error(e); // <- e is AxiosError and e is the response of the last retry
}

I would appreciate it if you could point out if my post is not in line with the intent of the question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants