2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-11 18:02:32 +03:00

fix: added a option to choose between legacy and the new request/response interceptor ordering

* test: add request interceptor tests for legacy and ordered execution

* feat: add legacy interceptor request/response ordering option

---------

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Willian Agostini
2026-01-30 03:12:04 -03:00
committed by GitHub
parent 44b7c9f0c4
commit 569f028a58
6 changed files with 89 additions and 17 deletions
+11 -2
View File
@@ -8,6 +8,7 @@ import mergeConfig from './mergeConfig.js';
import buildFullPath from './buildFullPath.js';
import validator from '../helpers/validator.js';
import AxiosHeaders from './AxiosHeaders.js';
import transitionalDefaults from '../defaults/transitional.js';
const validators = validator.validators;
@@ -80,7 +81,8 @@ class Axios {
validator.assertOptions(transitional, {
silentJSONParsing: validators.transitional(validators.boolean),
forcedJSONParsing: validators.transitional(validators.boolean),
clarifyTimeoutError: validators.transitional(validators.boolean)
clarifyTimeoutError: validators.transitional(validators.boolean),
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
}, false);
}
@@ -139,7 +141,14 @@ class Axios {
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
const transitional = config.transitional || transitionalDefaults;
const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
if (legacyInterceptorReqResOrdering) {
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
} else {
requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
}
});
const responseInterceptorChain = [];
+2 -1
View File
@@ -3,5 +3,6 @@
export default {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
clarifyTimeoutError: false,
legacyInterceptorReqResOrdering: true
};