axios 1.13.1 → 1.13.3
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/CHANGELOG.md +85 -0
- package/MIGRATION_GUIDE.md +876 -2
- package/README.md +136 -81
- package/dist/axios.js +253 -150
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +2 -2
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +152 -168
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +152 -168
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +2 -2
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +210 -218
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +21 -3
- package/index.d.ts +27 -7
- package/lib/adapters/README.md +1 -1
- package/lib/adapters/http.js +35 -28
- package/lib/adapters/xhr.js +2 -2
- package/lib/cancel/CanceledError.js +15 -18
- package/lib/core/Axios.js +8 -3
- package/lib/core/AxiosError.js +65 -102
- package/lib/core/InterceptorManager.js +2 -1
- package/lib/core/mergeConfig.js +2 -3
- package/lib/core/transformData.js +1 -1
- package/lib/env/data.js +1 -1
- package/lib/helpers/buildURL.js +7 -10
- package/lib/helpers/composeSignals.js +1 -1
- package/lib/helpers/cookies.js +1 -1
- package/lib/helpers/isAxiosError.js +1 -1
- package/lib/helpers/parseHeaders.js +1 -1
- package/lib/helpers/spread.js +1 -1
- package/lib/utils.js +24 -7
- package/package.json +26 -2
package/index.d.cts
CHANGED
|
@@ -100,7 +100,7 @@ declare class AxiosError<T = unknown, D = any> extends Error {
|
|
|
100
100
|
isAxiosError: boolean;
|
|
101
101
|
status?: number;
|
|
102
102
|
toJSON: () => object;
|
|
103
|
-
cause?:
|
|
103
|
+
cause?: Error;
|
|
104
104
|
event?: BrowserProgressEvent;
|
|
105
105
|
static from<T = unknown, D = any>(
|
|
106
106
|
error: Error | unknown,
|
|
@@ -515,14 +515,32 @@ declare namespace axios {
|
|
|
515
515
|
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
-
type
|
|
518
|
+
type AxiosInterceptorFulfilled<T> = (value: T) => T | Promise<T>;
|
|
519
|
+
type AxiosInterceptorRejected = (error: any) => any;
|
|
519
520
|
|
|
520
|
-
type
|
|
521
|
+
type AxiosRequestInterceptorUse<T> = (
|
|
522
|
+
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
|
523
|
+
onRejected?: AxiosInterceptorRejected | null,
|
|
524
|
+
options?: AxiosInterceptorOptions
|
|
525
|
+
) => number;
|
|
526
|
+
|
|
527
|
+
type AxiosResponseInterceptorUse<T> = (
|
|
528
|
+
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
|
529
|
+
onRejected?: AxiosInterceptorRejected | null
|
|
530
|
+
) => number;
|
|
531
|
+
|
|
532
|
+
interface AxiosInterceptorHandler<T> {
|
|
533
|
+
fulfilled: AxiosInterceptorFulfilled<T>;
|
|
534
|
+
rejected?: AxiosInterceptorRejected;
|
|
535
|
+
synchronous: boolean;
|
|
536
|
+
runWhen?: (config: AxiosRequestConfig) => boolean;
|
|
537
|
+
}
|
|
521
538
|
|
|
522
539
|
interface AxiosInterceptorManager<V> {
|
|
523
540
|
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
|
524
541
|
eject(id: number): void;
|
|
525
542
|
clear(): void;
|
|
543
|
+
handlers?: Array<AxiosInterceptorHandler<V>>;
|
|
526
544
|
}
|
|
527
545
|
|
|
528
546
|
interface AxiosInstance extends Axios {
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// TypeScript Version: 4.7
|
|
2
|
+
type StringLiteralsOrString<Literals extends string> = Literals | (string & {});
|
|
3
|
+
|
|
2
4
|
export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
|
|
3
5
|
|
|
4
6
|
interface RawAxiosHeaders {
|
|
@@ -302,7 +304,7 @@ export interface AxiosProgressEvent {
|
|
|
302
304
|
|
|
303
305
|
type Milliseconds = number;
|
|
304
306
|
|
|
305
|
-
type AxiosAdapterName = '
|
|
307
|
+
type AxiosAdapterName = StringLiteralsOrString<'xhr' | 'http' | 'fetch'>;
|
|
306
308
|
|
|
307
309
|
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
|
308
310
|
|
|
@@ -317,7 +319,7 @@ export type LookupAddress = string | LookupAddressEntry;
|
|
|
317
319
|
|
|
318
320
|
export interface AxiosRequestConfig<D = any> {
|
|
319
321
|
url?: string;
|
|
320
|
-
method?: Method
|
|
322
|
+
method?: StringLiteralsOrString<Method>;
|
|
321
323
|
baseURL?: string;
|
|
322
324
|
allowAbsoluteUrls?: boolean;
|
|
323
325
|
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
|
@@ -332,7 +334,7 @@ export interface AxiosRequestConfig<D = any> {
|
|
|
332
334
|
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
|
|
333
335
|
auth?: AxiosBasicCredentials;
|
|
334
336
|
responseType?: ResponseType;
|
|
335
|
-
responseEncoding?: responseEncoding
|
|
337
|
+
responseEncoding?: StringLiteralsOrString<responseEncoding>;
|
|
336
338
|
xsrfCookieName?: string;
|
|
337
339
|
xsrfHeaderName?: string;
|
|
338
340
|
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
|
@@ -348,7 +350,7 @@ export interface AxiosRequestConfig<D = any> {
|
|
|
348
350
|
httpAgent?: any;
|
|
349
351
|
httpsAgent?: any;
|
|
350
352
|
proxy?: AxiosProxyConfig | false;
|
|
351
|
-
cancelToken?: CancelToken;
|
|
353
|
+
cancelToken?: CancelToken | undefined;
|
|
352
354
|
decompress?: boolean;
|
|
353
355
|
transitional?: TransitionalOptions;
|
|
354
356
|
signal?: GenericAbortSignal;
|
|
@@ -429,7 +431,7 @@ export class AxiosError<T = unknown, D = any> extends Error {
|
|
|
429
431
|
isAxiosError: boolean;
|
|
430
432
|
status?: number;
|
|
431
433
|
toJSON: () => object;
|
|
432
|
-
cause?:
|
|
434
|
+
cause?: Error;
|
|
433
435
|
event?: BrowserProgressEvent;
|
|
434
436
|
static from<T = unknown, D = any>(
|
|
435
437
|
error: Error | unknown,
|
|
@@ -492,14 +494,32 @@ export interface AxiosInterceptorOptions {
|
|
|
492
494
|
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
|
493
495
|
}
|
|
494
496
|
|
|
495
|
-
type
|
|
497
|
+
type AxiosInterceptorFulfilled<T> = (value: T) => T | Promise<T>;
|
|
498
|
+
type AxiosInterceptorRejected = (error: any) => any;
|
|
499
|
+
|
|
500
|
+
type AxiosRequestInterceptorUse<T> = (
|
|
501
|
+
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
|
502
|
+
onRejected?: AxiosInterceptorRejected | null,
|
|
503
|
+
options?: AxiosInterceptorOptions
|
|
504
|
+
) => number;
|
|
496
505
|
|
|
497
|
-
type AxiosResponseInterceptorUse<T> = (
|
|
506
|
+
type AxiosResponseInterceptorUse<T> = (
|
|
507
|
+
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
|
508
|
+
onRejected?: AxiosInterceptorRejected | null
|
|
509
|
+
) => number;
|
|
510
|
+
|
|
511
|
+
interface AxiosInterceptorHandler<T> {
|
|
512
|
+
fulfilled: AxiosInterceptorFulfilled<T>;
|
|
513
|
+
rejected?: AxiosInterceptorRejected;
|
|
514
|
+
synchronous: boolean;
|
|
515
|
+
runWhen: (config: AxiosRequestConfig) => boolean | null;
|
|
516
|
+
}
|
|
498
517
|
|
|
499
518
|
export interface AxiosInterceptorManager<V> {
|
|
500
519
|
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
|
501
520
|
eject(id: number): void;
|
|
502
521
|
clear(): void;
|
|
522
|
+
handlers?: Array<AxiosInterceptorHandler<V>>;
|
|
503
523
|
}
|
|
504
524
|
|
|
505
525
|
export class Axios {
|
package/lib/adapters/README.md
CHANGED
package/lib/adapters/http.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import settle from './../core/settle.js';
|
|
1
|
+
import utils from '../utils.js';
|
|
2
|
+
import settle from '../core/settle.js';
|
|
4
3
|
import buildFullPath from '../core/buildFullPath.js';
|
|
5
|
-
import buildURL from '
|
|
4
|
+
import buildURL from '../helpers/buildURL.js';
|
|
6
5
|
import proxyFromEnv from 'proxy-from-env';
|
|
7
6
|
import http from 'http';
|
|
8
7
|
import https from 'https';
|
|
8
|
+
import http2 from 'http2';
|
|
9
9
|
import util from 'util';
|
|
10
10
|
import followRedirects from 'follow-redirects';
|
|
11
11
|
import zlib from 'zlib';
|
|
@@ -36,13 +36,6 @@ const brotliOptions = {
|
|
|
36
36
|
finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const {
|
|
40
|
-
HTTP2_HEADER_SCHEME,
|
|
41
|
-
HTTP2_HEADER_METHOD,
|
|
42
|
-
HTTP2_HEADER_PATH,
|
|
43
|
-
HTTP2_HEADER_STATUS
|
|
44
|
-
} = constants;
|
|
45
|
-
|
|
46
39
|
const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress);
|
|
47
40
|
|
|
48
41
|
const {http: httpFollow, https: httpsFollow} = followRedirects;
|
|
@@ -72,9 +65,9 @@ class Http2Sessions {
|
|
|
72
65
|
sessionTimeout: 1000
|
|
73
66
|
}, options);
|
|
74
67
|
|
|
75
|
-
let authoritySessions;
|
|
68
|
+
let authoritySessions = this.sessions[authority];
|
|
76
69
|
|
|
77
|
-
if (
|
|
70
|
+
if (authoritySessions) {
|
|
78
71
|
let len = authoritySessions.length;
|
|
79
72
|
|
|
80
73
|
for (let i = 0; i < len; i++) {
|
|
@@ -85,7 +78,7 @@ class Http2Sessions {
|
|
|
85
78
|
}
|
|
86
79
|
}
|
|
87
80
|
|
|
88
|
-
const session = connect(authority, options);
|
|
81
|
+
const session = http2.connect(authority, options);
|
|
89
82
|
|
|
90
83
|
let removed;
|
|
91
84
|
|
|
@@ -100,11 +93,12 @@ class Http2Sessions {
|
|
|
100
93
|
|
|
101
94
|
while (i--) {
|
|
102
95
|
if (entries[i][0] === session) {
|
|
103
|
-
entries.splice(i, 1);
|
|
104
96
|
if (len === 1) {
|
|
105
97
|
delete this.sessions[authority];
|
|
106
|
-
|
|
98
|
+
} else {
|
|
99
|
+
entries.splice(i, 1);
|
|
107
100
|
}
|
|
101
|
+
return;
|
|
108
102
|
}
|
|
109
103
|
}
|
|
110
104
|
};
|
|
@@ -143,12 +137,12 @@ class Http2Sessions {
|
|
|
143
137
|
|
|
144
138
|
session.once('close', removeSession);
|
|
145
139
|
|
|
146
|
-
let
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
let entry = [
|
|
141
|
+
session,
|
|
142
|
+
options
|
|
143
|
+
];
|
|
150
144
|
|
|
151
|
-
|
|
145
|
+
authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
|
|
152
146
|
|
|
153
147
|
return session;
|
|
154
148
|
}
|
|
@@ -199,12 +193,16 @@ function setProxy(options, configProxy, location) {
|
|
|
199
193
|
|
|
200
194
|
if (proxy.auth) {
|
|
201
195
|
// Support proxy auth object form
|
|
202
|
-
|
|
196
|
+
const validProxyAuth = Boolean(proxy.auth.username || proxy.auth.password);
|
|
197
|
+
|
|
198
|
+
if (validProxyAuth) {
|
|
203
199
|
proxy.auth = (proxy.auth.username || '') + ':' + (proxy.auth.password || '');
|
|
200
|
+
} else if (typeof proxy.auth === 'object') {
|
|
201
|
+
throw new AxiosError('Invalid proxy authorization', AxiosError.ERR_BAD_OPTION, { proxy });
|
|
204
202
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
203
|
+
|
|
204
|
+
const base64 = Buffer.from(proxy.auth, 'utf8').toString('base64');
|
|
205
|
+
|
|
208
206
|
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
|
|
209
207
|
}
|
|
210
208
|
|
|
@@ -270,12 +268,20 @@ const buildAddressEntry = (address, family) => resolveFamily(utils.isObject(addr
|
|
|
270
268
|
|
|
271
269
|
const http2Transport = {
|
|
272
270
|
request(options, cb) {
|
|
273
|
-
const authority = options.protocol + '//' + options.hostname + ':' + (options.port || 80);
|
|
271
|
+
const authority = options.protocol + '//' + options.hostname + ':' + (options.port ||(options.protocol === 'https:' ? 443 : 80));
|
|
272
|
+
|
|
274
273
|
|
|
275
274
|
const {http2Options, headers} = options;
|
|
276
275
|
|
|
277
276
|
const session = http2Sessions.getSession(authority, http2Options);
|
|
278
277
|
|
|
278
|
+
const {
|
|
279
|
+
HTTP2_HEADER_SCHEME,
|
|
280
|
+
HTTP2_HEADER_METHOD,
|
|
281
|
+
HTTP2_HEADER_PATH,
|
|
282
|
+
HTTP2_HEADER_STATUS
|
|
283
|
+
} = http2.constants;
|
|
284
|
+
|
|
279
285
|
const http2Headers = {
|
|
280
286
|
[HTTP2_HEADER_SCHEME]: options.protocol.replace(':', ''),
|
|
281
287
|
[HTTP2_HEADER_METHOD]: options.method,
|
|
@@ -811,8 +817,6 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
811
817
|
|
|
812
818
|
// Handle errors
|
|
813
819
|
req.on('error', function handleRequestError(err) {
|
|
814
|
-
// @todo remove
|
|
815
|
-
// if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
|
|
816
820
|
reject(AxiosError.from(err, null, config, req));
|
|
817
821
|
});
|
|
818
822
|
|
|
@@ -857,6 +861,9 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
857
861
|
req
|
|
858
862
|
));
|
|
859
863
|
});
|
|
864
|
+
} else {
|
|
865
|
+
// explicitly reset the socket timeout value for a possible `keep-alive` request
|
|
866
|
+
req.setTimeout(0);
|
|
860
867
|
}
|
|
861
868
|
|
|
862
869
|
|
package/lib/adapters/xhr.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import utils from '
|
|
2
|
-
import settle from '
|
|
1
|
+
import utils from '../utils.js';
|
|
2
|
+
import settle from '../core/settle.js';
|
|
3
3
|
import transitionalDefaults from '../defaults/transitional.js';
|
|
4
4
|
import AxiosError from '../core/AxiosError.js';
|
|
5
5
|
import CanceledError from '../cancel/CanceledError.js';
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import AxiosError from '../core/AxiosError.js';
|
|
4
|
-
import utils from '../utils.js';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
class CanceledError extends AxiosError {
|
|
6
|
+
/**
|
|
7
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
8
|
+
*
|
|
9
|
+
* @param {string=} message The message.
|
|
10
|
+
* @param {Object=} config The config.
|
|
11
|
+
* @param {Object=} request The request.
|
|
12
|
+
*
|
|
13
|
+
* @returns {CanceledError} The created error.
|
|
14
|
+
*/
|
|
15
|
+
constructor(message, config, request) {
|
|
16
|
+
super(message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
|
17
|
+
this.name = 'CanceledError';
|
|
18
|
+
this.__CANCEL__ = true;
|
|
19
|
+
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
utils.inherits(CanceledError, AxiosError, {
|
|
22
|
-
__CANCEL__: true
|
|
23
|
-
});
|
|
24
|
-
|
|
25
22
|
export default CanceledError;
|
package/lib/core/Axios.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import utils from '
|
|
3
|
+
import utils from '../utils.js';
|
|
4
4
|
import buildURL from '../helpers/buildURL.js';
|
|
5
5
|
import InterceptorManager from './InterceptorManager.js';
|
|
6
6
|
import dispatchRequest from './dispatchRequest.js';
|
|
@@ -159,8 +159,13 @@ class Axios {
|
|
|
159
159
|
|
|
160
160
|
promise = Promise.resolve(config);
|
|
161
161
|
|
|
162
|
+
let prevResult = config;
|
|
162
163
|
while (i < len) {
|
|
163
|
-
promise = promise
|
|
164
|
+
promise = promise
|
|
165
|
+
.then(chain[i++])
|
|
166
|
+
.then(result => { prevResult = result !== undefined ? result : prevResult })
|
|
167
|
+
.catch(chain[i++])
|
|
168
|
+
.then(() => prevResult);
|
|
164
169
|
}
|
|
165
170
|
|
|
166
171
|
return promise;
|
|
@@ -191,7 +196,7 @@ class Axios {
|
|
|
191
196
|
len = responseInterceptorChain.length;
|
|
192
197
|
|
|
193
198
|
while (i < len) {
|
|
194
|
-
promise = promise.then(responseInterceptorChain[i++]
|
|
199
|
+
promise = promise.then(responseInterceptorChain[i++]).catch(responseInterceptorChain[i++]);
|
|
195
200
|
}
|
|
196
201
|
|
|
197
202
|
return promise;
|
package/lib/core/AxiosError.js
CHANGED
|
@@ -2,109 +2,72 @@
|
|
|
2
2
|
|
|
3
3
|
import utils from '../utils.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
5
|
+
class AxiosError extends Error {
|
|
6
|
+
static from(error, code, config, request, response, customProps) {
|
|
7
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
8
|
+
axiosError.cause = error;
|
|
9
|
+
axiosError.name = error.name;
|
|
10
|
+
customProps && Object.assign(axiosError, customProps);
|
|
11
|
+
return axiosError;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} message The error message.
|
|
18
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
19
|
+
* @param {Object} [config] The config.
|
|
20
|
+
* @param {Object} [request] The request.
|
|
21
|
+
* @param {Object} [response] The response.
|
|
22
|
+
*
|
|
23
|
+
* @returns {Error} The created error.
|
|
24
|
+
*/
|
|
25
|
+
constructor(message, code, config, request, response) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = 'AxiosError';
|
|
28
|
+
this.isAxiosError = true;
|
|
29
|
+
code && (this.code = code);
|
|
30
|
+
config && (this.config = config);
|
|
31
|
+
request && (this.request = request);
|
|
32
|
+
if (response) {
|
|
33
|
+
this.response = response;
|
|
34
|
+
this.status = response.status;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
toJSON() {
|
|
39
|
+
return {
|
|
40
|
+
// Standard
|
|
41
|
+
message: this.message,
|
|
42
|
+
name: this.name,
|
|
43
|
+
// Microsoft
|
|
44
|
+
description: this.description,
|
|
45
|
+
number: this.number,
|
|
46
|
+
// Mozilla
|
|
47
|
+
fileName: this.fileName,
|
|
48
|
+
lineNumber: this.lineNumber,
|
|
49
|
+
columnNumber: this.columnNumber,
|
|
50
|
+
stack: this.stack,
|
|
51
|
+
// Axios
|
|
52
|
+
config: utils.toJSONObject(this.config),
|
|
53
|
+
code: this.code,
|
|
54
|
+
status: this.status,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
34
57
|
}
|
|
35
58
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
stack: this.stack,
|
|
50
|
-
// Axios
|
|
51
|
-
config: utils.toJSONObject(this.config),
|
|
52
|
-
code: this.code,
|
|
53
|
-
status: this.status
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const prototype = AxiosError.prototype;
|
|
59
|
-
const descriptors = {};
|
|
60
|
-
|
|
61
|
-
[
|
|
62
|
-
'ERR_BAD_OPTION_VALUE',
|
|
63
|
-
'ERR_BAD_OPTION',
|
|
64
|
-
'ECONNABORTED',
|
|
65
|
-
'ETIMEDOUT',
|
|
66
|
-
'ERR_NETWORK',
|
|
67
|
-
'ERR_FR_TOO_MANY_REDIRECTS',
|
|
68
|
-
'ERR_DEPRECATED',
|
|
69
|
-
'ERR_BAD_RESPONSE',
|
|
70
|
-
'ERR_BAD_REQUEST',
|
|
71
|
-
'ERR_CANCELED',
|
|
72
|
-
'ERR_NOT_SUPPORT',
|
|
73
|
-
'ERR_INVALID_URL'
|
|
74
|
-
// eslint-disable-next-line func-names
|
|
75
|
-
].forEach(code => {
|
|
76
|
-
descriptors[code] = {value: code};
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
Object.defineProperties(AxiosError, descriptors);
|
|
80
|
-
Object.defineProperty(prototype, 'isAxiosError', {value: true});
|
|
81
|
-
|
|
82
|
-
// eslint-disable-next-line func-names
|
|
83
|
-
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
84
|
-
const axiosError = Object.create(prototype);
|
|
85
|
-
|
|
86
|
-
utils.toFlatObject(error, axiosError, function filter(obj) {
|
|
87
|
-
return obj !== Error.prototype;
|
|
88
|
-
}, prop => {
|
|
89
|
-
return prop !== 'isAxiosError';
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const msg = error && error.message ? error.message : 'Error';
|
|
93
|
-
|
|
94
|
-
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
95
|
-
const errCode = code == null && error ? error.code : code;
|
|
96
|
-
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
97
|
-
|
|
98
|
-
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
99
|
-
if (error && axiosError.cause == null) {
|
|
100
|
-
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
axiosError.name = (error && error.name) || 'Error';
|
|
104
|
-
|
|
105
|
-
customProps && Object.assign(axiosError, customProps);
|
|
106
|
-
|
|
107
|
-
return axiosError;
|
|
108
|
-
};
|
|
59
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
60
|
+
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
61
|
+
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
62
|
+
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
63
|
+
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
64
|
+
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
65
|
+
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
66
|
+
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
67
|
+
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
68
|
+
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
69
|
+
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
70
|
+
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
71
|
+
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
109
72
|
|
|
110
73
|
export default AxiosError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import utils from '
|
|
3
|
+
import utils from '../utils.js';
|
|
4
4
|
|
|
5
5
|
class InterceptorManager {
|
|
6
6
|
constructor() {
|
|
@@ -12,6 +12,7 @@ class InterceptorManager {
|
|
|
12
12
|
*
|
|
13
13
|
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
14
14
|
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
15
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
15
16
|
*
|
|
16
17
|
* @return {Number} An ID used to remove interceptor later
|
|
17
18
|
*/
|
package/lib/core/mergeConfig.js
CHANGED
|
@@ -21,7 +21,7 @@ export default function mergeConfig(config1, config2) {
|
|
|
21
21
|
|
|
22
22
|
function getMergedValue(target, source, prop, caseless) {
|
|
23
23
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
24
|
-
return utils.merge.call({caseless}, target, source);
|
|
24
|
+
return utils.merge.call({ caseless }, target, source);
|
|
25
25
|
} else if (utils.isPlainObject(source)) {
|
|
26
26
|
return utils.merge({}, source);
|
|
27
27
|
} else if (utils.isArray(source)) {
|
|
@@ -30,7 +30,6 @@ export default function mergeConfig(config1, config2) {
|
|
|
30
30
|
return source;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// eslint-disable-next-line consistent-return
|
|
34
33
|
function mergeDeepProperties(a, b, prop, caseless) {
|
|
35
34
|
if (!utils.isUndefined(b)) {
|
|
36
35
|
return getMergedValue(a, b, prop, caseless);
|
|
@@ -96,7 +95,7 @@ export default function mergeConfig(config1, config2) {
|
|
|
96
95
|
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
97
96
|
};
|
|
98
97
|
|
|
99
|
-
utils.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
98
|
+
utils.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
100
99
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
101
100
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
102
101
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
package/lib/env/data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.13.
|
|
1
|
+
export const VERSION = "1.13.3";
|
package/lib/helpers/buildURL.js
CHANGED
|
@@ -29,29 +29,26 @@ function encode(val) {
|
|
|
29
29
|
* @returns {string} The formatted url
|
|
30
30
|
*/
|
|
31
31
|
export default function buildURL(url, params, options) {
|
|
32
|
-
/*eslint no-param-reassign:0*/
|
|
33
32
|
if (!params) {
|
|
34
33
|
return url;
|
|
35
34
|
}
|
|
36
|
-
|
|
35
|
+
|
|
37
36
|
const _encode = options && options.encode || encode;
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
options
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
}
|
|
38
|
+
const _options = utils.isFunction(options) ? {
|
|
39
|
+
serialize: options
|
|
40
|
+
} : options;
|
|
44
41
|
|
|
45
|
-
const serializeFn =
|
|
42
|
+
const serializeFn = _options && _options.serialize;
|
|
46
43
|
|
|
47
44
|
let serializedParams;
|
|
48
45
|
|
|
49
46
|
if (serializeFn) {
|
|
50
|
-
serializedParams = serializeFn(params,
|
|
47
|
+
serializedParams = serializeFn(params, _options);
|
|
51
48
|
} else {
|
|
52
49
|
serializedParams = utils.isURLSearchParams(params) ?
|
|
53
50
|
params.toString() :
|
|
54
|
-
new AxiosURLSearchParams(params,
|
|
51
|
+
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
if (serializedParams) {
|
|
@@ -21,7 +21,7 @@ const composeSignals = (signals, timeout) => {
|
|
|
21
21
|
|
|
22
22
|
let timer = timeout && setTimeout(() => {
|
|
23
23
|
timer = null;
|
|
24
|
-
onabort(new AxiosError(`timeout ${timeout}
|
|
24
|
+
onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT))
|
|
25
25
|
}, timeout)
|
|
26
26
|
|
|
27
27
|
const unsubscribe = () => {
|
package/lib/helpers/cookies.js
CHANGED