-
Notifications
You must be signed in to change notification settings - Fork 45
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
Expose axios interceptor api #43
Comments
|
In that case, I would propose one of the following things: a) change rapidjs documentation so that it says in order to use interceptors, you need to override the b) provide a a function on the Rapid-Object with the same signature as axios that does a) for you. So that you can call inside the constructor c) ask axios maintainers to expose What do you think? |
@M3psipax sorry for my late answer
That was my first thought, too :)
That's a nice solution. But
I kind of fell in love with your workaround honestly. This makes the class Base extends Rapid{
.....
initializeAPI() {
super.initializeAPI();
this.interceptor = this.api.interceptors.response.use(response => {
//response interception
return response;
}, error => {
// error interception
return Promise.reject(error.response);
});
}
ejectInterceptor() {
this.api.interceptors.eject(this.interceptor);
}
} Thanks again for your feedback and thought, that helps a lot! @drewjbartlett what do you think, any thoughts on this? |
There is a problem with the current behaviour of the interceptor as explained by @M3psipax in detail here.
Basically:
We should use axios
InterceptorManager
to fully expose axios interceptor capabilities.The text was updated successfully, but these errors were encountered: