@varlet/axle 0.2.12 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/package.json +1 -1
package/es/index.d.ts
CHANGED
|
@@ -55,8 +55,8 @@ interface ResponseRetryInterceptorOptions {
|
|
|
55
55
|
declare function responseRetryInterceptor(options: ResponseRetryInterceptorOptions): ResponseInterceptor;
|
|
56
56
|
|
|
57
57
|
interface ResponseStatusInterceptorOptions {
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
validStatusHandler?: Record<number | string, (response: AxiosResponse<any, any>) => any>;
|
|
59
|
+
invalidStatusHandler?: Record<number | string, (error: any) => any>;
|
|
60
60
|
include?: string[];
|
|
61
61
|
exclude?: string[];
|
|
62
62
|
axiosInterceptorOptions?: AxiosInterceptorOptions;
|
package/es/index.js
CHANGED
|
@@ -296,7 +296,7 @@ function responseStatusInterceptor(options) {
|
|
|
296
296
|
if (!matcher((_a = response.config.method) != null ? _a : "", (_b = response.config.url) != null ? _b : "")) {
|
|
297
297
|
return response;
|
|
298
298
|
}
|
|
299
|
-
const handler = ((_c = options.
|
|
299
|
+
const handler = ((_c = options.validStatusHandler) != null ? _c : {})[response.status];
|
|
300
300
|
if (!handler) {
|
|
301
301
|
return response;
|
|
302
302
|
}
|
|
@@ -309,7 +309,7 @@ function responseStatusInterceptor(options) {
|
|
|
309
309
|
if (!matcher((_a = error.config.method) != null ? _a : "", (_b = error.config.url) != null ? _b : "")) {
|
|
310
310
|
return Promise.reject(error);
|
|
311
311
|
}
|
|
312
|
-
const handler = ((_c = options.
|
|
312
|
+
const handler = ((_c = options.invalidStatusHandler) != null ? _c : {})[error.response.status];
|
|
313
313
|
if (!handler) {
|
|
314
314
|
return Promise.reject(error);
|
|
315
315
|
}
|