-
Notifications
You must be signed in to change notification settings - Fork 58
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
Adding automatic retries on network and 5xx errors #61
Conversation
Retries 3 times by default, and only on network errors and 5xx errors on indempotent requests (GET, HEAD, OPTIONS, PUT, or DELETE).
This should fix this issue. |
Update comments
Thanks for this simple fix, saves me a lot of unnecessary headaches! Would be great to add an error handling example in the README |
Just the one question from me, otherwise I really like the option of replacing the axios instance. |
@yakovkhalinsky what is the question? |
@Amit-A just wonder why you wrap the object with |
@yakovkhalinsky |
allows an optional axios config object that overrides the default axios config | ||
creates new axios instance so that axios-retry isn't injected into the user's code if they also use axios | ||
*/ | ||
const axiosClient = axios.create(Object.assign({ /* no defaults for now */ }, options.axios)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious about the reasoning for using Object.assign()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh it's not really necessary in that case - it's just there so that we can add defaults in the future if necessary.
Retries 3 times by default, and only on network errors and 5xx errors on indempotent requests (GET, HEAD, OPTIONS, PUT, or DELETE).