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

Why axios-retry config didn't lose? #55

Closed
zgayjjf opened this issue Jul 7, 2018 · 2 comments
Closed

Why axios-retry config didn't lose? #55

zgayjjf opened this issue Jul 7, 2018 · 2 comments
Labels

Comments

@zgayjjf
Copy link

zgayjjf commented Jul 7, 2018

Hello there,

Axios-retry is a excellent lib.
I'm reading it's code, and there is something I don't understand.

According to the code here and here, Axios will only merge some predefined attributes on config, which means axios-retry config will get lost.

However, axios-retry works just fine, and config didn't lose.

This makes me confused, and I can't figure out why is that.

Any help will be appreciated.

@mawrkus
Copy link
Contributor

mawrkus commented Jun 14, 2019

If I understand correctly your question, the answer is here https://github.com/axios/axios/blob/master/lib/core/Axios.js#L37

All the properties of config object are merged, not only predefined ones.
This allows axios-retry to add its own internal config here https://github.com/softonic/axios-retry/blob/master/es/index.js#L89

Hope this helps.

@zgayjjf
Copy link
Author

zgayjjf commented Jun 17, 2019

@mawrkus Thanks for the reply.

I figured it out.

Axios-retry never extends Axios's default config. It uses interceptors to add its config before every request is sent.

https://github.com/softonic/axios-retry/blob/master/es/index.js#L175

This explains everything.

BTW, Axios doesn't merge properties that are not predefined.

@zgayjjf zgayjjf closed this as completed Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants