axios 1.2.0-alpha.1 → 1.2.1
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.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +48 -1
- package/README.md +6 -5
- package/dist/axios.js +401 -351
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +470 -404
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +482 -415
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +422 -368
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +3 -0
- package/index.d.ts +18 -4
- package/index.js +4 -2
- package/lib/adapters/adapters.js +59 -0
- package/lib/adapters/http.js +36 -26
- package/lib/adapters/xhr.js +5 -3
- package/lib/axios.js +3 -0
- package/lib/core/AxiosError.js +1 -1
- package/lib/core/dispatchRequest.js +3 -2
- package/lib/defaults/index.js +1 -20
- package/lib/env/data.js +1 -1
- package/lib/helpers/speedometer.js +1 -1
- package/lib/platform/browser/index.js +19 -0
- package/lib/utils.js +33 -1
- package/package.json +2 -2
- package/lib/adapters/index.js +0 -33
package/index.d.cts
CHANGED
@@ -321,6 +321,8 @@ declare namespace axios {
|
|
321
321
|
serialize?: CustomParamsSerializer;
|
322
322
|
}
|
323
323
|
|
324
|
+
type BrowserProgressEvent = any;
|
325
|
+
|
324
326
|
interface AxiosProgressEvent {
|
325
327
|
loaded: number;
|
326
328
|
total?: number;
|
@@ -330,6 +332,7 @@ declare namespace axios {
|
|
330
332
|
estimated?: number;
|
331
333
|
upload?: boolean;
|
332
334
|
download?: boolean;
|
335
|
+
event?: BrowserProgressEvent;
|
333
336
|
}
|
334
337
|
|
335
338
|
interface AxiosRequestConfig<D = any> {
|
package/index.d.ts
CHANGED
@@ -6,7 +6,7 @@ type MethodsHeaders = {
|
|
6
6
|
[Key in Method as Lowercase<Key>]: AxiosHeaders;
|
7
7
|
};
|
8
8
|
|
9
|
-
interface CommonHeaders
|
9
|
+
interface CommonHeaders {
|
10
10
|
common: AxiosHeaders;
|
11
11
|
}
|
12
12
|
|
@@ -263,6 +263,8 @@ type MaxUploadRate = number;
|
|
263
263
|
|
264
264
|
type MaxDownloadRate = number;
|
265
265
|
|
266
|
+
type BrowserProgressEvent = any;
|
267
|
+
|
266
268
|
export interface AxiosProgressEvent {
|
267
269
|
loaded: number;
|
268
270
|
total?: number;
|
@@ -272,11 +274,15 @@ export interface AxiosProgressEvent {
|
|
272
274
|
estimated?: number;
|
273
275
|
upload?: boolean;
|
274
276
|
download?: boolean;
|
275
|
-
event?:
|
277
|
+
event?: BrowserProgressEvent;
|
276
278
|
}
|
277
279
|
|
278
280
|
type Milliseconds = number;
|
279
281
|
|
282
|
+
type AxiosAdapterName = 'xhr' | 'http' | string;
|
283
|
+
|
284
|
+
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
285
|
+
|
280
286
|
export interface AxiosRequestConfig<D = any> {
|
281
287
|
url?: string;
|
282
288
|
method?: Method | string;
|
@@ -290,7 +296,7 @@ export interface AxiosRequestConfig<D = any> {
|
|
290
296
|
timeout?: Milliseconds;
|
291
297
|
timeoutErrorMessage?: string;
|
292
298
|
withCredentials?: boolean;
|
293
|
-
adapter?:
|
299
|
+
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
|
294
300
|
auth?: AxiosBasicCredentials;
|
295
301
|
responseType?: ResponseType;
|
296
302
|
responseEncoding?: responseEncoding | string;
|
@@ -341,7 +347,7 @@ export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>
|
|
341
347
|
headers?: RawAxiosRequestHeaders | Partial<HeadersDefaults>;
|
342
348
|
}
|
343
349
|
|
344
|
-
export interface AxiosResponse<T = any, D = any>
|
350
|
+
export interface AxiosResponse<T = any, D = any> {
|
345
351
|
data: T;
|
346
352
|
status: number;
|
347
353
|
statusText: string;
|
@@ -367,6 +373,14 @@ export class AxiosError<T = unknown, D = any> extends Error {
|
|
367
373
|
status?: number;
|
368
374
|
toJSON: () => object;
|
369
375
|
cause?: Error;
|
376
|
+
static from<T = unknown, D = any>(
|
377
|
+
error: Error | unknown,
|
378
|
+
code?: string,
|
379
|
+
config?: AxiosRequestConfig<D>,
|
380
|
+
request?: any,
|
381
|
+
response?: AxiosResponse<T, D>,
|
382
|
+
customProps?: object,
|
383
|
+
): AxiosError<T, D>;
|
370
384
|
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
371
385
|
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
372
386
|
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
package/index.js
CHANGED
@@ -16,7 +16,8 @@ const {
|
|
16
16
|
spread,
|
17
17
|
toFormData,
|
18
18
|
AxiosHeaders,
|
19
|
-
formToJSON
|
19
|
+
formToJSON,
|
20
|
+
mergeConfig
|
20
21
|
} = axios;
|
21
22
|
|
22
23
|
export {
|
@@ -33,5 +34,6 @@ export {
|
|
33
34
|
spread,
|
34
35
|
toFormData,
|
35
36
|
AxiosHeaders,
|
36
|
-
formToJSON
|
37
|
+
formToJSON,
|
38
|
+
mergeConfig
|
37
39
|
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import utils from '../utils.js';
|
2
|
+
import httpAdapter from './http.js';
|
3
|
+
import xhrAdapter from './xhr.js';
|
4
|
+
import AxiosError from "../core/AxiosError.js";
|
5
|
+
|
6
|
+
const knownAdapters = {
|
7
|
+
http: httpAdapter,
|
8
|
+
xhr: xhrAdapter
|
9
|
+
}
|
10
|
+
|
11
|
+
utils.forEach(knownAdapters, (fn, value) => {
|
12
|
+
if(fn) {
|
13
|
+
try {
|
14
|
+
Object.defineProperty(fn, 'name', {value});
|
15
|
+
} catch (e) {
|
16
|
+
// eslint-disable-next-line no-empty
|
17
|
+
}
|
18
|
+
Object.defineProperty(fn, 'adapterName', {value});
|
19
|
+
}
|
20
|
+
});
|
21
|
+
|
22
|
+
export default {
|
23
|
+
getAdapter: (adapters) => {
|
24
|
+
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
25
|
+
|
26
|
+
const {length} = adapters;
|
27
|
+
let nameOrAdapter;
|
28
|
+
let adapter;
|
29
|
+
|
30
|
+
for (let i = 0; i < length; i++) {
|
31
|
+
nameOrAdapter = adapters[i];
|
32
|
+
if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
|
33
|
+
break;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
if (!adapter) {
|
38
|
+
if (adapter === false) {
|
39
|
+
throw new AxiosError(
|
40
|
+
`Adapter ${nameOrAdapter} is not supported by the environment`,
|
41
|
+
'ERR_NOT_SUPPORT'
|
42
|
+
);
|
43
|
+
}
|
44
|
+
|
45
|
+
throw new Error(
|
46
|
+
utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
|
47
|
+
`Adapter '${nameOrAdapter}' is not available in the build` :
|
48
|
+
`Unknown adapter '${nameOrAdapter}'`
|
49
|
+
);
|
50
|
+
}
|
51
|
+
|
52
|
+
if (!utils.isFunction(adapter)) {
|
53
|
+
throw new TypeError('adapter is not a function');
|
54
|
+
}
|
55
|
+
|
56
|
+
return adapter;
|
57
|
+
},
|
58
|
+
adapters: knownAdapters
|
59
|
+
}
|
package/lib/adapters/http.js
CHANGED
@@ -20,6 +20,11 @@ import AxiosHeaders from '../core/AxiosHeaders.js';
|
|
20
20
|
import AxiosTransformStream from '../helpers/AxiosTransformStream.js';
|
21
21
|
import EventEmitter from 'events';
|
22
22
|
|
23
|
+
const zlibOptions = {
|
24
|
+
flush: zlib.constants.Z_SYNC_FLUSH,
|
25
|
+
finishFlush: zlib.constants.Z_SYNC_FLUSH
|
26
|
+
}
|
27
|
+
|
23
28
|
const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress);
|
24
29
|
|
25
30
|
const {http: httpFollow, https: httpsFollow} = followRedirects;
|
@@ -100,8 +105,10 @@ function setProxy(options, configProxy, location) {
|
|
100
105
|
};
|
101
106
|
}
|
102
107
|
|
108
|
+
const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process';
|
109
|
+
|
103
110
|
/*eslint consistent-return:0*/
|
104
|
-
export default function httpAdapter(config) {
|
111
|
+
export default isHttpAdapterSupported && function httpAdapter(config) {
|
105
112
|
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
106
113
|
let data = config.data;
|
107
114
|
const responseType = config.responseType;
|
@@ -260,7 +267,7 @@ export default function httpAdapter(config) {
|
|
260
267
|
}
|
261
268
|
}
|
262
269
|
|
263
|
-
const contentLength =
|
270
|
+
const contentLength = utils.toFiniteNumber(headers.getContentLength());
|
264
271
|
|
265
272
|
if (utils.isArray(maxRate)) {
|
266
273
|
maxUploadRate = maxRate[0];
|
@@ -275,7 +282,7 @@ export default function httpAdapter(config) {
|
|
275
282
|
}
|
276
283
|
|
277
284
|
data = stream.pipeline([data, new AxiosTransformStream({
|
278
|
-
length:
|
285
|
+
length: contentLength,
|
279
286
|
maxRate: utils.toFiniteNumber(maxUploadRate)
|
280
287
|
})], utils.noop);
|
281
288
|
|
@@ -318,7 +325,10 @@ export default function httpAdapter(config) {
|
|
318
325
|
return reject(customErr);
|
319
326
|
}
|
320
327
|
|
321
|
-
headers.set(
|
328
|
+
headers.set(
|
329
|
+
'Accept-Encoding',
|
330
|
+
'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false
|
331
|
+
);
|
322
332
|
|
323
333
|
const options = {
|
324
334
|
path,
|
@@ -373,17 +383,34 @@ export default function httpAdapter(config) {
|
|
373
383
|
|
374
384
|
const streams = [res];
|
375
385
|
|
376
|
-
|
386
|
+
const responseLength = +res.headers['content-length'];
|
387
|
+
|
388
|
+
if (onDownloadProgress) {
|
389
|
+
const transformStream = new AxiosTransformStream({
|
390
|
+
length: utils.toFiniteNumber(responseLength),
|
391
|
+
maxRate: utils.toFiniteNumber(maxDownloadRate)
|
392
|
+
});
|
393
|
+
|
394
|
+
onDownloadProgress && transformStream.on('progress', progress => {
|
395
|
+
onDownloadProgress(Object.assign(progress, {
|
396
|
+
download: true
|
397
|
+
}));
|
398
|
+
});
|
399
|
+
|
400
|
+
streams.push(transformStream);
|
401
|
+
}
|
402
|
+
|
403
|
+
// decompress the response body transparently if required
|
377
404
|
let responseStream = res;
|
378
405
|
|
379
406
|
// return the last request in case of redirects
|
380
407
|
const lastRequest = res.req || req;
|
381
408
|
|
382
409
|
// if decompress disabled we should not decompress
|
383
|
-
if (config.decompress !== false) {
|
410
|
+
if (config.decompress !== false && res.headers['content-encoding']) {
|
384
411
|
// if no content, but headers still say that it is encoded,
|
385
412
|
// remove the header not confuse downstream operations
|
386
|
-
if (
|
413
|
+
if (method === 'HEAD' || res.statusCode === 204) {
|
387
414
|
delete res.headers['content-encoding'];
|
388
415
|
}
|
389
416
|
|
@@ -393,36 +420,19 @@ export default function httpAdapter(config) {
|
|
393
420
|
case 'compress':
|
394
421
|
case 'deflate':
|
395
422
|
// add the unzipper to the body stream processing pipeline
|
396
|
-
streams.push(zlib.createUnzip());
|
423
|
+
streams.push(zlib.createUnzip(zlibOptions));
|
397
424
|
|
398
425
|
// remove the content-encoding in order to not confuse downstream operations
|
399
426
|
delete res.headers['content-encoding'];
|
400
427
|
break;
|
401
428
|
case 'br':
|
402
429
|
if (isBrotliSupported) {
|
403
|
-
streams.push(zlib.createBrotliDecompress());
|
430
|
+
streams.push(zlib.createBrotliDecompress(zlibOptions));
|
404
431
|
delete res.headers['content-encoding'];
|
405
432
|
}
|
406
433
|
}
|
407
434
|
}
|
408
435
|
|
409
|
-
if (onDownloadProgress) {
|
410
|
-
const responseLength = +res.headers['content-length'];
|
411
|
-
|
412
|
-
const transformStream = new AxiosTransformStream({
|
413
|
-
length: utils.toFiniteNumber(responseLength),
|
414
|
-
maxRate: utils.toFiniteNumber(maxDownloadRate)
|
415
|
-
});
|
416
|
-
|
417
|
-
onDownloadProgress && transformStream.on('progress', progress => {
|
418
|
-
onDownloadProgress(Object.assign(progress, {
|
419
|
-
download: true
|
420
|
-
}));
|
421
|
-
});
|
422
|
-
|
423
|
-
streams.push(transformStream);
|
424
|
-
}
|
425
|
-
|
426
436
|
responseStream = streams.length > 1 ? stream.pipeline(streams, utils.noop) : streams[0];
|
427
437
|
|
428
438
|
const offListeners = stream.finished(responseStream, () => {
|
package/lib/adapters/xhr.js
CHANGED
@@ -43,7 +43,9 @@ function progressEventReducer(listener, isDownloadStream) {
|
|
43
43
|
};
|
44
44
|
}
|
45
45
|
|
46
|
-
|
46
|
+
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
47
|
+
|
48
|
+
export default isXHRAdapterSupported && function (config) {
|
47
49
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
48
50
|
let requestData = config.data;
|
49
51
|
const requestHeaders = AxiosHeaders.from(config.headers).normalize();
|
@@ -59,7 +61,7 @@ export default function xhrAdapter(config) {
|
|
59
61
|
}
|
60
62
|
}
|
61
63
|
|
62
|
-
if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
|
64
|
+
if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
|
63
65
|
requestHeaders.setContentType(false); // Let the browser set it
|
64
66
|
}
|
65
67
|
|
@@ -87,7 +89,7 @@ export default function xhrAdapter(config) {
|
|
87
89
|
const responseHeaders = AxiosHeaders.from(
|
88
90
|
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
89
91
|
);
|
90
|
-
const responseData = !responseType || responseType === 'text' ||
|
92
|
+
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
91
93
|
request.responseText : request.response;
|
92
94
|
const response = {
|
93
95
|
data: responseData,
|
package/lib/axios.js
CHANGED
@@ -70,6 +70,9 @@ axios.spread = spread;
|
|
70
70
|
// Expose isAxiosError
|
71
71
|
axios.isAxiosError = isAxiosError;
|
72
72
|
|
73
|
+
// Expose mergeConfig
|
74
|
+
axios.mergeConfig = mergeConfig;
|
75
|
+
|
73
76
|
axios.AxiosHeaders = AxiosHeaders;
|
74
77
|
|
75
78
|
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
package/lib/core/AxiosError.js
CHANGED
@@ -45,7 +45,7 @@ utils.inherits(AxiosError, Error, {
|
|
45
45
|
columnNumber: this.columnNumber,
|
46
46
|
stack: this.stack,
|
47
47
|
// Axios
|
48
|
-
config: this.config,
|
48
|
+
config: utils.toJSONObject(this.config),
|
49
49
|
code: this.code,
|
50
50
|
status: this.response && this.response.status ? this.response.status : null
|
51
51
|
};
|
@@ -5,6 +5,7 @@ import isCancel from '../cancel/isCancel.js';
|
|
5
5
|
import defaults from '../defaults/index.js';
|
6
6
|
import CanceledError from '../cancel/CanceledError.js';
|
7
7
|
import AxiosHeaders from '../core/AxiosHeaders.js';
|
8
|
+
import adapters from "../adapters/adapters.js";
|
8
9
|
|
9
10
|
/**
|
10
11
|
* Throws a `CanceledError` if cancellation has been requested.
|
@@ -19,7 +20,7 @@ function throwIfCancellationRequested(config) {
|
|
19
20
|
}
|
20
21
|
|
21
22
|
if (config.signal && config.signal.aborted) {
|
22
|
-
throw new CanceledError();
|
23
|
+
throw new CanceledError(null, config);
|
23
24
|
}
|
24
25
|
}
|
25
26
|
|
@@ -45,7 +46,7 @@ export default function dispatchRequest(config) {
|
|
45
46
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
46
47
|
}
|
47
48
|
|
48
|
-
const adapter = config.adapter || defaults.adapter;
|
49
|
+
const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
|
49
50
|
|
50
51
|
return adapter(config).then(function onAdapterResolution(response) {
|
51
52
|
throwIfCancellationRequested(config);
|
package/lib/defaults/index.js
CHANGED
@@ -7,30 +7,11 @@ import toFormData from '../helpers/toFormData.js';
|
|
7
7
|
import toURLEncodedForm from '../helpers/toURLEncodedForm.js';
|
8
8
|
import platform from '../platform/index.js';
|
9
9
|
import formDataToJSON from '../helpers/formDataToJSON.js';
|
10
|
-
import adapters from '../adapters/index.js';
|
11
10
|
|
12
11
|
const DEFAULT_CONTENT_TYPE = {
|
13
12
|
'Content-Type': undefined
|
14
13
|
};
|
15
14
|
|
16
|
-
/**
|
17
|
-
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
|
18
|
-
* adapter
|
19
|
-
*
|
20
|
-
* @returns {Function}
|
21
|
-
*/
|
22
|
-
function getDefaultAdapter() {
|
23
|
-
let adapter;
|
24
|
-
if (typeof XMLHttpRequest !== 'undefined') {
|
25
|
-
// For browsers use XHR adapter
|
26
|
-
adapter = adapters.getAdapter('xhr');
|
27
|
-
} else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
|
28
|
-
// For node use HTTP adapter
|
29
|
-
adapter = adapters.getAdapter('http');
|
30
|
-
}
|
31
|
-
return adapter;
|
32
|
-
}
|
33
|
-
|
34
15
|
/**
|
35
16
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
36
17
|
* of the input
|
@@ -60,7 +41,7 @@ const defaults = {
|
|
60
41
|
|
61
42
|
transitional: transitionalDefaults,
|
62
43
|
|
63
|
-
adapter:
|
44
|
+
adapter: ['xhr', 'http'],
|
64
45
|
|
65
46
|
transformRequest: [function transformRequest(data, headers) {
|
66
47
|
const contentType = headers.getContentType() || '';
|
package/lib/env/data.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "1.2.
|
1
|
+
export const VERSION = "1.2.1";
|
@@ -31,6 +31,24 @@ const isStandardBrowserEnv = (() => {
|
|
31
31
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
32
32
|
})();
|
33
33
|
|
34
|
+
/**
|
35
|
+
* Determine if we're running in a standard browser webWorker environment
|
36
|
+
*
|
37
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
38
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
39
|
+
* filtered out due to its judgment standard
|
40
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
41
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
42
|
+
*/
|
43
|
+
const isStandardBrowserWebWorkerEnv = (() => {
|
44
|
+
return (
|
45
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
46
|
+
self instanceof WorkerGlobalScope &&
|
47
|
+
typeof self.importScripts === 'function'
|
48
|
+
);
|
49
|
+
})();
|
50
|
+
|
51
|
+
|
34
52
|
export default {
|
35
53
|
isBrowser: true,
|
36
54
|
classes: {
|
@@ -39,5 +57,6 @@ export default {
|
|
39
57
|
Blob
|
40
58
|
},
|
41
59
|
isStandardBrowserEnv,
|
60
|
+
isStandardBrowserWebWorkerEnv,
|
42
61
|
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
43
62
|
};
|
package/lib/utils.js
CHANGED
@@ -592,6 +592,37 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
592
592
|
return Number.isFinite(value) ? value : defaultValue;
|
593
593
|
}
|
594
594
|
|
595
|
+
const toJSONObject = (obj) => {
|
596
|
+
const stack = new Array(10);
|
597
|
+
|
598
|
+
const visit = (source, i) => {
|
599
|
+
|
600
|
+
if (isObject(source)) {
|
601
|
+
if (stack.indexOf(source) >= 0) {
|
602
|
+
return;
|
603
|
+
}
|
604
|
+
|
605
|
+
if(!('toJSON' in source)) {
|
606
|
+
stack[i] = source;
|
607
|
+
const target = isArray(source) ? [] : {};
|
608
|
+
|
609
|
+
forEach(source, (value, key) => {
|
610
|
+
const reducedValue = visit(value, i + 1);
|
611
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
612
|
+
});
|
613
|
+
|
614
|
+
stack[i] = undefined;
|
615
|
+
|
616
|
+
return target;
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
620
|
+
return source;
|
621
|
+
}
|
622
|
+
|
623
|
+
return visit(obj, 0);
|
624
|
+
}
|
625
|
+
|
595
626
|
export default {
|
596
627
|
isArray,
|
597
628
|
isArrayBuffer,
|
@@ -637,5 +668,6 @@ export default {
|
|
637
668
|
toFiniteNumber,
|
638
669
|
findKey,
|
639
670
|
global: _global,
|
640
|
-
isContextDefined
|
671
|
+
isContextDefined,
|
672
|
+
toJSONObject
|
641
673
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "axios",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.1",
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
5
5
|
"main": "index.js",
|
6
6
|
"exports": {
|
@@ -104,7 +104,7 @@
|
|
104
104
|
"url-search-params": "^0.10.0"
|
105
105
|
},
|
106
106
|
"browser": {
|
107
|
-
"./lib/adapters/http.js": "./lib/
|
107
|
+
"./lib/adapters/http.js": "./lib/helpers/null.js",
|
108
108
|
"./lib/platform/node/index.js": "./lib/platform/browser/index.js"
|
109
109
|
},
|
110
110
|
"jsdelivr": "dist/axios.min.js",
|
package/lib/adapters/index.js
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
import utils from '../utils.js';
|
2
|
-
import httpAdapter from './http.js';
|
3
|
-
import xhrAdapter from './xhr.js';
|
4
|
-
|
5
|
-
const adapters = {
|
6
|
-
http: httpAdapter,
|
7
|
-
xhr: xhrAdapter
|
8
|
-
}
|
9
|
-
|
10
|
-
export default {
|
11
|
-
getAdapter: (nameOrAdapter) => {
|
12
|
-
if(utils.isString(nameOrAdapter)){
|
13
|
-
const adapter = adapters[nameOrAdapter];
|
14
|
-
|
15
|
-
if (!nameOrAdapter) {
|
16
|
-
throw Error(
|
17
|
-
utils.hasOwnProp(nameOrAdapter) ?
|
18
|
-
`Adapter '${nameOrAdapter}' is not available in the build` :
|
19
|
-
`Can not resolve adapter '${nameOrAdapter}'`
|
20
|
-
);
|
21
|
-
}
|
22
|
-
|
23
|
-
return adapter
|
24
|
-
}
|
25
|
-
|
26
|
-
if (!utils.isFunction(nameOrAdapter)) {
|
27
|
-
throw new TypeError('adapter is not a function');
|
28
|
-
}
|
29
|
-
|
30
|
-
return nameOrAdapter;
|
31
|
-
},
|
32
|
-
adapters
|
33
|
-
}
|