2
0
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:
Tackoil
2026-01-09 03:11:34 +08:00
committed by GitHub
parent 7373fbff24
commit 5945e40bb1
2 changed files with 80 additions and 2 deletions
+7 -2
View File
@@ -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;