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
runWhen option for response interceptors #4792
Comments
I ran into that problem while configuring the response interceptors too. The const requestInterceptorChain = [];
let synchronousRequestInterceptors = true;
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
return;
}
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
});
const responseInterceptorChain = [];
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
}); I have no idea why it was designed so but you can actually set the btw, the request interceptors are invoked in the reversed order, notice that /* request interceptors have a reversed execution order */ There are several issues and pull requests related to this feature. It's still not documented or changed, together with the Maybe you can workaround it by modifying the source by now. Here's a forked version I did, hope it can be helpful. npm - axios-no-reverse. Note that I also changed the execution order of request interceptors. |
Ping in 2023 for understanding the rationale here of |
+1 |
Is your feature request related to a problem? Please describe.
It is impossible to define runWhen function for response interceprtors.
Describe the solution you'd like
I would love to have the possibility of defining the runWhen option for response interceptors
Describe alternatives you've considered
Additional context
it is useful sometimes,
The text was updated successfully, but these errors were encountered: