mirror of
https://github.com/tenrok/axios.git
synced 2026-06-11 18:02:32 +03:00
fix(interceptor): handle the error in the same interceptor (#6269)
* fix(interceptor): handle the error in the same interceptor * fix(interceptor): pass the config and data in promise chain * fix(interceptor): filter out unexpected config and data in promise chain --------- Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
+7
-2
@@ -159,8 +159,13 @@ class Axios {
|
||||
|
||||
promise = Promise.resolve(config);
|
||||
|
||||
let prevResult = config;
|
||||
while (i < len) {
|
||||
promise = promise.then(chain[i++], chain[i++]);
|
||||
promise = promise
|
||||
.then(chain[i++])
|
||||
.then(result => { prevResult = result !== undefined ? result : prevResult })
|
||||
.catch(chain[i++])
|
||||
.then(() => prevResult);
|
||||
}
|
||||
|
||||
return promise;
|
||||
@@ -191,7 +196,7 @@ class Axios {
|
||||
len = responseInterceptorChain.length;
|
||||
|
||||
while (i < len) {
|
||||
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
||||
promise = promise.then(responseInterceptorChain[i++]).catch(responseInterceptorChain[i++]);
|
||||
}
|
||||
|
||||
return promise;
|
||||
|
||||
Reference in New Issue
Block a user