-
-
Notifications
You must be signed in to change notification settings - Fork 11k
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 that possible to add different Interceptors for different request? #108
Comments
It is indeed really bad to add the interceptors to the global object. Makes it impossible to use two different node modules that both require axios with their own interceptors. |
@deyhle I am agree to use different node modules. But node will cache the module when you require it at first time. So when I add interceptors to one of them, all axios will have the interceptors. I have check the source code, the axios does not use factory pattern to exports its instance. |
You can now create instances of axios using axios.interceptors.request.use((config) => {
config.foo = 123;
});
const instance = axios.create();
instance.interceptors.request.use((config) => {
config.foo = 456;
});
axios.get('/foo'); // config.foo === 123 -> true
instance.get('/foo'); // config.foo === 456 -> true |
hi everyone is there any posiibility to create an interceptor in electron js project ? |
Right now, the axios only support add/remove
Interceptors
to the global axios instance.For example:
Right now, I have to add another method to filter out some requests base on the url.
The text was updated successfully, but these errors were encountered: