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
how to break promise chain in interceptors? #715
Comments
I don't recommend you doing so, but if you finally want it you can return a never-resolving promise in your interceptors. E.g.: instance.interceptors.response.use((response) => {
if (someCondition(response) {
return new Promise(() => {});
}
return response;
}); |
I didn't like the idea of using a promise that never resolves or rejects, so I opted to use bluebird's cancellation to do something like this: axios.interceptors.response.use(null, error => {
let promise = new Promise(resolve, reject) => {
setTimeout(() => {
<code>
promise.cancel()
})
})
return promise
}) the setTimeout allows the promise to initalize itself so that a proper promise is still returned from the interceptor and |
Reply to @rubennorte:
https://stackoverflow.com/a/20068922
|
How to break promise chain?
in angular:
http://blog.zeit.io/stop-a-promise-chain-without-using-reject-with-angular-s-q/
in bluebird:
http://openmymind.net/Cancelling-Long-Promise-Chains/
the above examples break chains in
then()
, can axios break it also in interceptor, somthing likes:The text was updated successfully, but these errors were encountered: