axios 1.1.3 → 1.2.0
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 +139 -74
- package/{UPGRADE_GUIDE.md → MIGRATION_GUIDE.md} +1 -1
- package/README.md +59 -22
- package/dist/axios.js +754 -576
- 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 +3054 -0
- package/dist/browser/axios.cjs.map +1 -0
- package/dist/esm/axios.js +719 -595
- 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 +618 -517
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +490 -0
- package/index.d.ts +33 -11
- package/index.js +8 -3
- package/karma.conf.cjs +1 -1
- package/lib/adapters/adapters.js +59 -0
- package/lib/adapters/http.js +23 -21
- package/lib/adapters/xhr.js +5 -2
- package/lib/axios.js +7 -3
- package/lib/core/Axios.js +10 -8
- package/lib/core/AxiosError.js +1 -1
- package/lib/core/AxiosHeaders.js +82 -76
- package/lib/core/dispatchRequest.js +6 -1
- package/lib/core/mergeConfig.js +50 -46
- package/lib/defaults/index.js +2 -21
- package/lib/env/data.js +1 -1
- package/lib/utils.js +68 -8
- package/package.json +14 -7
- package/rollup.config.js +37 -10
- package/tsconfig.json +2 -7
- package/tslint.json +6 -1
- package/lib/adapters/index.js +0 -33
package/dist/node/axios.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.
|
1
|
+
// Axios v1.2.0 Copyright (c) 2022 Matt Zabriskie and contributors
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
const FormData$1 = require('form-data');
|
@@ -254,7 +254,7 @@ const trim = (str) => str.trim ?
|
|
254
254
|
* @param {Function} fn The callback to invoke for each item
|
255
255
|
*
|
256
256
|
* @param {Boolean} [allOwnKeys = false]
|
257
|
-
* @returns {
|
257
|
+
* @returns {any}
|
258
258
|
*/
|
259
259
|
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
260
260
|
// Don't bother if no value provided
|
@@ -289,6 +289,24 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
289
289
|
}
|
290
290
|
}
|
291
291
|
|
292
|
+
function findKey(obj, key) {
|
293
|
+
key = key.toLowerCase();
|
294
|
+
const keys = Object.keys(obj);
|
295
|
+
let i = keys.length;
|
296
|
+
let _key;
|
297
|
+
while (i-- > 0) {
|
298
|
+
_key = keys[i];
|
299
|
+
if (key === _key.toLowerCase()) {
|
300
|
+
return _key;
|
301
|
+
}
|
302
|
+
}
|
303
|
+
return null;
|
304
|
+
}
|
305
|
+
|
306
|
+
const _global = typeof self === "undefined" ? typeof global === "undefined" ? undefined : global : self;
|
307
|
+
|
308
|
+
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
309
|
+
|
292
310
|
/**
|
293
311
|
* Accepts varargs expecting each argument to be an object, then
|
294
312
|
* immutably merges the properties of each object and returns result.
|
@@ -308,16 +326,18 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
308
326
|
* @returns {Object} Result of all merge properties
|
309
327
|
*/
|
310
328
|
function merge(/* obj1, obj2, obj3, ... */) {
|
329
|
+
const {caseless} = isContextDefined(this) && this || {};
|
311
330
|
const result = {};
|
312
331
|
const assignValue = (val, key) => {
|
313
|
-
|
314
|
-
|
332
|
+
const targetKey = caseless && findKey(result, key) || key;
|
333
|
+
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
334
|
+
result[targetKey] = merge(result[targetKey], val);
|
315
335
|
} else if (isPlainObject(val)) {
|
316
|
-
result[
|
336
|
+
result[targetKey] = merge({}, val);
|
317
337
|
} else if (isArray(val)) {
|
318
|
-
result[
|
338
|
+
result[targetKey] = val.slice();
|
319
339
|
} else {
|
320
|
-
result[
|
340
|
+
result[targetKey] = val;
|
321
341
|
}
|
322
342
|
};
|
323
343
|
|
@@ -553,6 +573,11 @@ const reduceDescriptors = (obj, reducer) => {
|
|
553
573
|
|
554
574
|
const freezeMethods = (obj) => {
|
555
575
|
reduceDescriptors(obj, (descriptor, name) => {
|
576
|
+
// skip restricted props in strict mode
|
577
|
+
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
578
|
+
return false;
|
579
|
+
}
|
580
|
+
|
556
581
|
const value = obj[name];
|
557
582
|
|
558
583
|
if (!isFunction(value)) return;
|
@@ -566,7 +591,7 @@ const freezeMethods = (obj) => {
|
|
566
591
|
|
567
592
|
if (!descriptor.set) {
|
568
593
|
descriptor.set = () => {
|
569
|
-
throw Error('Can not read-only method \'' + name + '\'');
|
594
|
+
throw Error('Can not rewrite read-only method \'' + name + '\'');
|
570
595
|
};
|
571
596
|
}
|
572
597
|
});
|
@@ -593,6 +618,37 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
593
618
|
return Number.isFinite(value) ? value : defaultValue;
|
594
619
|
};
|
595
620
|
|
621
|
+
const toJSONObject = (obj) => {
|
622
|
+
const stack = new Array(10);
|
623
|
+
|
624
|
+
const visit = (source, i) => {
|
625
|
+
|
626
|
+
if (isObject(source)) {
|
627
|
+
if (stack.indexOf(source) >= 0) {
|
628
|
+
return;
|
629
|
+
}
|
630
|
+
|
631
|
+
if(!('toJSON' in source)) {
|
632
|
+
stack[i] = source;
|
633
|
+
const target = isArray(source) ? [] : {};
|
634
|
+
|
635
|
+
forEach(source, (value, key) => {
|
636
|
+
const reducedValue = visit(value, i + 1);
|
637
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
638
|
+
});
|
639
|
+
|
640
|
+
stack[i] = undefined;
|
641
|
+
|
642
|
+
return target;
|
643
|
+
}
|
644
|
+
}
|
645
|
+
|
646
|
+
return source;
|
647
|
+
};
|
648
|
+
|
649
|
+
return visit(obj, 0);
|
650
|
+
};
|
651
|
+
|
596
652
|
const utils = {
|
597
653
|
isArray,
|
598
654
|
isArrayBuffer,
|
@@ -635,7 +691,11 @@ const utils = {
|
|
635
691
|
toObjectSet,
|
636
692
|
toCamelCase,
|
637
693
|
noop,
|
638
|
-
toFiniteNumber
|
694
|
+
toFiniteNumber,
|
695
|
+
findKey,
|
696
|
+
global: _global,
|
697
|
+
isContextDefined,
|
698
|
+
toJSONObject
|
639
699
|
};
|
640
700
|
|
641
701
|
/**
|
@@ -681,7 +741,7 @@ utils.inherits(AxiosError, Error, {
|
|
681
741
|
columnNumber: this.columnNumber,
|
682
742
|
stack: this.stack,
|
683
743
|
// Axios
|
684
|
-
config: this.config,
|
744
|
+
config: utils.toJSONObject(this.config),
|
685
745
|
code: this.code,
|
686
746
|
status: this.response && this.response.status ? this.response.status : null
|
687
747
|
};
|
@@ -1133,6 +1193,8 @@ class InterceptorManager {
|
|
1133
1193
|
}
|
1134
1194
|
}
|
1135
1195
|
|
1196
|
+
const InterceptorManager$1 = InterceptorManager;
|
1197
|
+
|
1136
1198
|
const transitionalDefaults = {
|
1137
1199
|
silentJSONParsing: true,
|
1138
1200
|
forcedJSONParsing: true,
|
@@ -1251,148 +1313,162 @@ function formDataToJSON(formData) {
|
|
1251
1313
|
return null;
|
1252
1314
|
}
|
1253
1315
|
|
1316
|
+
const DEFAULT_CONTENT_TYPE = {
|
1317
|
+
'Content-Type': undefined
|
1318
|
+
};
|
1319
|
+
|
1254
1320
|
/**
|
1255
|
-
*
|
1321
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
1322
|
+
* of the input
|
1256
1323
|
*
|
1257
|
-
* @param {
|
1258
|
-
* @param {Function}
|
1259
|
-
* @param {
|
1324
|
+
* @param {any} rawValue - The value to be stringified.
|
1325
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
1326
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
1260
1327
|
*
|
1261
|
-
* @returns {
|
1328
|
+
* @returns {string} A stringified version of the rawValue.
|
1262
1329
|
*/
|
1263
|
-
function
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
response
|
1274
|
-
));
|
1330
|
+
function stringifySafely(rawValue, parser, encoder) {
|
1331
|
+
if (utils.isString(rawValue)) {
|
1332
|
+
try {
|
1333
|
+
(parser || JSON.parse)(rawValue);
|
1334
|
+
return utils.trim(rawValue);
|
1335
|
+
} catch (e) {
|
1336
|
+
if (e.name !== 'SyntaxError') {
|
1337
|
+
throw e;
|
1338
|
+
}
|
1339
|
+
}
|
1275
1340
|
}
|
1276
|
-
}
|
1277
1341
|
|
1278
|
-
|
1279
|
-
* Determines whether the specified URL is absolute
|
1280
|
-
*
|
1281
|
-
* @param {string} url The URL to test
|
1282
|
-
*
|
1283
|
-
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
1284
|
-
*/
|
1285
|
-
function isAbsoluteURL(url) {
|
1286
|
-
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
1287
|
-
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
1288
|
-
// by any combination of letters, digits, plus, period, or hyphen.
|
1289
|
-
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
1342
|
+
return (encoder || JSON.stringify)(rawValue);
|
1290
1343
|
}
|
1291
1344
|
|
1292
|
-
|
1293
|
-
* Creates a new URL by combining the specified URLs
|
1294
|
-
*
|
1295
|
-
* @param {string} baseURL The base URL
|
1296
|
-
* @param {string} relativeURL The relative URL
|
1297
|
-
*
|
1298
|
-
* @returns {string} The combined URL
|
1299
|
-
*/
|
1300
|
-
function combineURLs(baseURL, relativeURL) {
|
1301
|
-
return relativeURL
|
1302
|
-
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
1303
|
-
: baseURL;
|
1304
|
-
}
|
1345
|
+
const defaults = {
|
1305
1346
|
|
1306
|
-
|
1307
|
-
* Creates a new URL by combining the baseURL with the requestedURL,
|
1308
|
-
* only when the requestedURL is not already an absolute URL.
|
1309
|
-
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
1310
|
-
*
|
1311
|
-
* @param {string} baseURL The base URL
|
1312
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
1313
|
-
*
|
1314
|
-
* @returns {string} The combined full path
|
1315
|
-
*/
|
1316
|
-
function buildFullPath(baseURL, requestedURL) {
|
1317
|
-
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
1318
|
-
return combineURLs(baseURL, requestedURL);
|
1319
|
-
}
|
1320
|
-
return requestedURL;
|
1321
|
-
}
|
1347
|
+
transitional: transitionalDefaults,
|
1322
1348
|
|
1323
|
-
|
1349
|
+
adapter: ['xhr', 'http'],
|
1324
1350
|
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
* @param {Object=} config The config.
|
1330
|
-
* @param {Object=} request The request.
|
1331
|
-
*
|
1332
|
-
* @returns {CanceledError} The created error.
|
1333
|
-
*/
|
1334
|
-
function CanceledError(message, config, request) {
|
1335
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
1336
|
-
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
1337
|
-
this.name = 'CanceledError';
|
1338
|
-
}
|
1351
|
+
transformRequest: [function transformRequest(data, headers) {
|
1352
|
+
const contentType = headers.getContentType() || '';
|
1353
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
1354
|
+
const isObjectPayload = utils.isObject(data);
|
1339
1355
|
|
1340
|
-
utils.
|
1341
|
-
|
1342
|
-
}
|
1356
|
+
if (isObjectPayload && utils.isHTMLForm(data)) {
|
1357
|
+
data = new FormData(data);
|
1358
|
+
}
|
1343
1359
|
|
1344
|
-
|
1345
|
-
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
1346
|
-
return match && match[1] || '';
|
1347
|
-
}
|
1360
|
+
const isFormData = utils.isFormData(data);
|
1348
1361
|
|
1349
|
-
|
1362
|
+
if (isFormData) {
|
1363
|
+
if (!hasJSONContentType) {
|
1364
|
+
return data;
|
1365
|
+
}
|
1366
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
1367
|
+
}
|
1350
1368
|
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1369
|
+
if (utils.isArrayBuffer(data) ||
|
1370
|
+
utils.isBuffer(data) ||
|
1371
|
+
utils.isStream(data) ||
|
1372
|
+
utils.isFile(data) ||
|
1373
|
+
utils.isBlob(data)
|
1374
|
+
) {
|
1375
|
+
return data;
|
1376
|
+
}
|
1377
|
+
if (utils.isArrayBufferView(data)) {
|
1378
|
+
return data.buffer;
|
1379
|
+
}
|
1380
|
+
if (utils.isURLSearchParams(data)) {
|
1381
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
1382
|
+
return data.toString();
|
1383
|
+
}
|
1364
1384
|
|
1365
|
-
|
1366
|
-
asBlob = true;
|
1367
|
-
}
|
1385
|
+
let isFileList;
|
1368
1386
|
|
1369
|
-
|
1370
|
-
|
1387
|
+
if (isObjectPayload) {
|
1388
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
1389
|
+
return toURLEncodedForm(data, this.formSerializer).toString();
|
1390
|
+
}
|
1371
1391
|
|
1372
|
-
|
1392
|
+
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
1393
|
+
const _FormData = this.env && this.env.FormData;
|
1373
1394
|
|
1374
|
-
|
1375
|
-
|
1395
|
+
return toFormData(
|
1396
|
+
isFileList ? {'files[]': data} : data,
|
1397
|
+
_FormData && new _FormData(),
|
1398
|
+
this.formSerializer
|
1399
|
+
);
|
1400
|
+
}
|
1376
1401
|
}
|
1377
1402
|
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1403
|
+
if (isObjectPayload || hasJSONContentType ) {
|
1404
|
+
headers.setContentType('application/json', false);
|
1405
|
+
return stringifySafely(data);
|
1406
|
+
}
|
1382
1407
|
|
1383
|
-
|
1384
|
-
|
1385
|
-
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
1386
|
-
}
|
1408
|
+
return data;
|
1409
|
+
}],
|
1387
1410
|
|
1388
|
-
|
1411
|
+
transformResponse: [function transformResponse(data) {
|
1412
|
+
const transitional = this.transitional || defaults.transitional;
|
1413
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
1414
|
+
const JSONRequested = this.responseType === 'json';
|
1415
|
+
|
1416
|
+
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
1417
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
1418
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
1419
|
+
|
1420
|
+
try {
|
1421
|
+
return JSON.parse(data);
|
1422
|
+
} catch (e) {
|
1423
|
+
if (strictJSONParsing) {
|
1424
|
+
if (e.name === 'SyntaxError') {
|
1425
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
1426
|
+
}
|
1427
|
+
throw e;
|
1428
|
+
}
|
1429
|
+
}
|
1389
1430
|
}
|
1390
1431
|
|
1391
|
-
return
|
1432
|
+
return data;
|
1433
|
+
}],
|
1434
|
+
|
1435
|
+
/**
|
1436
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
1437
|
+
* timeout is not created.
|
1438
|
+
*/
|
1439
|
+
timeout: 0,
|
1440
|
+
|
1441
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
1442
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
1443
|
+
|
1444
|
+
maxContentLength: -1,
|
1445
|
+
maxBodyLength: -1,
|
1446
|
+
|
1447
|
+
env: {
|
1448
|
+
FormData: platform.classes.FormData,
|
1449
|
+
Blob: platform.classes.Blob
|
1450
|
+
},
|
1451
|
+
|
1452
|
+
validateStatus: function validateStatus(status) {
|
1453
|
+
return status >= 200 && status < 300;
|
1454
|
+
},
|
1455
|
+
|
1456
|
+
headers: {
|
1457
|
+
common: {
|
1458
|
+
'Accept': 'application/json, text/plain, */*'
|
1459
|
+
}
|
1392
1460
|
}
|
1461
|
+
};
|
1393
1462
|
|
1394
|
-
|
1395
|
-
}
|
1463
|
+
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
1464
|
+
defaults.headers[method] = {};
|
1465
|
+
});
|
1466
|
+
|
1467
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
1468
|
+
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
1469
|
+
});
|
1470
|
+
|
1471
|
+
const defaults$1 = defaults;
|
1396
1472
|
|
1397
1473
|
// RawAxiosHeaders whose duplicates are ignored by node
|
1398
1474
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
@@ -1447,7 +1523,6 @@ const parseHeaders = rawHeaders => {
|
|
1447
1523
|
};
|
1448
1524
|
|
1449
1525
|
const $internals = Symbol('internals');
|
1450
|
-
const $defaults = Symbol('defaults');
|
1451
1526
|
|
1452
1527
|
function normalizeHeader(header) {
|
1453
1528
|
return header && String(header).trim().toLowerCase();
|
@@ -1473,6 +1548,10 @@ function parseTokens(str) {
|
|
1473
1548
|
return tokens;
|
1474
1549
|
}
|
1475
1550
|
|
1551
|
+
function isValidHeaderName(str) {
|
1552
|
+
return /^[-_a-zA-Z]+$/.test(str.trim());
|
1553
|
+
}
|
1554
|
+
|
1476
1555
|
function matchHeaderValue(context, value, header, filter) {
|
1477
1556
|
if (utils.isFunction(filter)) {
|
1478
1557
|
return filter.call(this, value, header);
|
@@ -1509,27 +1588,12 @@ function buildAccessors(obj, header) {
|
|
1509
1588
|
});
|
1510
1589
|
}
|
1511
1590
|
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
let i = keys.length;
|
1516
|
-
let _key;
|
1517
|
-
while (i-- > 0) {
|
1518
|
-
_key = keys[i];
|
1519
|
-
if (key === _key.toLowerCase()) {
|
1520
|
-
return _key;
|
1521
|
-
}
|
1591
|
+
class AxiosHeaders {
|
1592
|
+
constructor(headers) {
|
1593
|
+
headers && this.set(headers);
|
1522
1594
|
}
|
1523
|
-
return null;
|
1524
|
-
}
|
1525
|
-
|
1526
|
-
function AxiosHeaders(headers, defaults) {
|
1527
|
-
headers && this.set(headers);
|
1528
|
-
this[$defaults] = defaults || null;
|
1529
|
-
}
|
1530
1595
|
|
1531
|
-
|
1532
|
-
set: function(header, valueOrRewrite, rewrite) {
|
1596
|
+
set(header, valueOrRewrite, rewrite) {
|
1533
1597
|
const self = this;
|
1534
1598
|
|
1535
1599
|
function setHeader(_value, _header, _rewrite) {
|
@@ -1539,69 +1603,70 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1539
1603
|
throw new Error('header name must be a non-empty string');
|
1540
1604
|
}
|
1541
1605
|
|
1542
|
-
const key = findKey(self, lHeader);
|
1606
|
+
const key = utils.findKey(self, lHeader);
|
1543
1607
|
|
1544
|
-
if
|
1545
|
-
|
1608
|
+
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
1609
|
+
self[key || _header] = normalizeValue(_value);
|
1546
1610
|
}
|
1547
|
-
|
1548
|
-
self[key || _header] = normalizeValue(_value);
|
1549
1611
|
}
|
1550
1612
|
|
1551
|
-
|
1552
|
-
utils.forEach(
|
1553
|
-
|
1554
|
-
|
1613
|
+
const setHeaders = (headers, _rewrite) =>
|
1614
|
+
utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
1615
|
+
|
1616
|
+
if (utils.isPlainObject(header) || header instanceof this.constructor) {
|
1617
|
+
setHeaders(header, valueOrRewrite);
|
1618
|
+
} else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
1619
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
1555
1620
|
} else {
|
1556
|
-
setHeader(valueOrRewrite, header, rewrite);
|
1621
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
1557
1622
|
}
|
1558
1623
|
|
1559
1624
|
return this;
|
1560
|
-
}
|
1625
|
+
}
|
1561
1626
|
|
1562
|
-
get
|
1627
|
+
get(header, parser) {
|
1563
1628
|
header = normalizeHeader(header);
|
1564
1629
|
|
1565
|
-
if (
|
1630
|
+
if (header) {
|
1631
|
+
const key = utils.findKey(this, header);
|
1566
1632
|
|
1567
|
-
|
1633
|
+
if (key) {
|
1634
|
+
const value = this[key];
|
1568
1635
|
|
1569
|
-
|
1570
|
-
|
1636
|
+
if (!parser) {
|
1637
|
+
return value;
|
1638
|
+
}
|
1571
1639
|
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1640
|
+
if (parser === true) {
|
1641
|
+
return parseTokens(value);
|
1642
|
+
}
|
1575
1643
|
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1644
|
+
if (utils.isFunction(parser)) {
|
1645
|
+
return parser.call(this, value, key);
|
1646
|
+
}
|
1579
1647
|
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1648
|
+
if (utils.isRegExp(parser)) {
|
1649
|
+
return parser.exec(value);
|
1650
|
+
}
|
1583
1651
|
|
1584
|
-
|
1585
|
-
return parser.exec(value);
|
1652
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
1586
1653
|
}
|
1587
|
-
|
1588
|
-
throw new TypeError('parser must be boolean|regexp|function');
|
1589
1654
|
}
|
1590
|
-
}
|
1655
|
+
}
|
1591
1656
|
|
1592
|
-
has
|
1657
|
+
has(header, matcher) {
|
1593
1658
|
header = normalizeHeader(header);
|
1594
1659
|
|
1595
1660
|
if (header) {
|
1596
|
-
const key = findKey(this, header);
|
1661
|
+
const key = utils.findKey(this, header);
|
1597
1662
|
|
1598
1663
|
return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1599
1664
|
}
|
1600
1665
|
|
1601
1666
|
return false;
|
1602
|
-
}
|
1667
|
+
}
|
1603
1668
|
|
1604
|
-
delete
|
1669
|
+
delete(header, matcher) {
|
1605
1670
|
const self = this;
|
1606
1671
|
let deleted = false;
|
1607
1672
|
|
@@ -1609,7 +1674,7 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1609
1674
|
_header = normalizeHeader(_header);
|
1610
1675
|
|
1611
1676
|
if (_header) {
|
1612
|
-
const key = findKey(self, _header);
|
1677
|
+
const key = utils.findKey(self, _header);
|
1613
1678
|
|
1614
1679
|
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
1615
1680
|
delete self[key];
|
@@ -1626,18 +1691,18 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1626
1691
|
}
|
1627
1692
|
|
1628
1693
|
return deleted;
|
1629
|
-
}
|
1694
|
+
}
|
1630
1695
|
|
1631
|
-
clear
|
1696
|
+
clear() {
|
1632
1697
|
return Object.keys(this).forEach(this.delete.bind(this));
|
1633
|
-
}
|
1698
|
+
}
|
1634
1699
|
|
1635
|
-
normalize
|
1700
|
+
normalize(format) {
|
1636
1701
|
const self = this;
|
1637
1702
|
const headers = {};
|
1638
1703
|
|
1639
1704
|
utils.forEach(this, (value, header) => {
|
1640
|
-
const key = findKey(headers, header);
|
1705
|
+
const key = utils.findKey(headers, header);
|
1641
1706
|
|
1642
1707
|
if (key) {
|
1643
1708
|
self[key] = normalizeValue(value);
|
@@ -1657,30 +1722,47 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1657
1722
|
});
|
1658
1723
|
|
1659
1724
|
return this;
|
1660
|
-
}
|
1725
|
+
}
|
1726
|
+
|
1727
|
+
concat(...targets) {
|
1728
|
+
return this.constructor.concat(this, ...targets);
|
1729
|
+
}
|
1661
1730
|
|
1662
|
-
toJSON
|
1731
|
+
toJSON(asStrings) {
|
1663
1732
|
const obj = Object.create(null);
|
1664
1733
|
|
1665
|
-
utils.forEach(
|
1666
|
-
(value,
|
1667
|
-
|
1668
|
-
obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value;
|
1669
|
-
});
|
1734
|
+
utils.forEach(this, (value, header) => {
|
1735
|
+
value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
|
1736
|
+
});
|
1670
1737
|
|
1671
1738
|
return obj;
|
1672
1739
|
}
|
1673
|
-
});
|
1674
1740
|
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1741
|
+
[Symbol.iterator]() {
|
1742
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
1743
|
+
}
|
1744
|
+
|
1745
|
+
toString() {
|
1746
|
+
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
1747
|
+
}
|
1748
|
+
|
1749
|
+
get [Symbol.toStringTag]() {
|
1750
|
+
return 'AxiosHeaders';
|
1751
|
+
}
|
1752
|
+
|
1753
|
+
static from(thing) {
|
1680
1754
|
return thing instanceof this ? thing : new this(thing);
|
1681
|
-
}
|
1755
|
+
}
|
1756
|
+
|
1757
|
+
static concat(first, ...targets) {
|
1758
|
+
const computed = new this(first);
|
1759
|
+
|
1760
|
+
targets.forEach((target) => computed.set(target));
|
1682
1761
|
|
1683
|
-
|
1762
|
+
return computed;
|
1763
|
+
}
|
1764
|
+
|
1765
|
+
static accessor(header) {
|
1684
1766
|
const internals = this[$internals] = (this[$internals] = {
|
1685
1767
|
accessors: {}
|
1686
1768
|
});
|
@@ -1688,25 +1770,197 @@ Object.assign(AxiosHeaders, {
|
|
1688
1770
|
const accessors = internals.accessors;
|
1689
1771
|
const prototype = this.prototype;
|
1690
1772
|
|
1691
|
-
function defineAccessor(_header) {
|
1692
|
-
const lHeader = normalizeHeader(_header);
|
1773
|
+
function defineAccessor(_header) {
|
1774
|
+
const lHeader = normalizeHeader(_header);
|
1775
|
+
|
1776
|
+
if (!accessors[lHeader]) {
|
1777
|
+
buildAccessors(prototype, _header);
|
1778
|
+
accessors[lHeader] = true;
|
1779
|
+
}
|
1780
|
+
}
|
1781
|
+
|
1782
|
+
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
1783
|
+
|
1784
|
+
return this;
|
1785
|
+
}
|
1786
|
+
}
|
1787
|
+
|
1788
|
+
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
|
1789
|
+
|
1790
|
+
utils.freezeMethods(AxiosHeaders.prototype);
|
1791
|
+
utils.freezeMethods(AxiosHeaders);
|
1792
|
+
|
1793
|
+
const AxiosHeaders$1 = AxiosHeaders;
|
1794
|
+
|
1795
|
+
/**
|
1796
|
+
* Transform the data for a request or a response
|
1797
|
+
*
|
1798
|
+
* @param {Array|Function} fns A single function or Array of functions
|
1799
|
+
* @param {?Object} response The response object
|
1800
|
+
*
|
1801
|
+
* @returns {*} The resulting transformed data
|
1802
|
+
*/
|
1803
|
+
function transformData(fns, response) {
|
1804
|
+
const config = this || defaults$1;
|
1805
|
+
const context = response || config;
|
1806
|
+
const headers = AxiosHeaders$1.from(context.headers);
|
1807
|
+
let data = context.data;
|
1808
|
+
|
1809
|
+
utils.forEach(fns, function transform(fn) {
|
1810
|
+
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
1811
|
+
});
|
1812
|
+
|
1813
|
+
headers.normalize();
|
1814
|
+
|
1815
|
+
return data;
|
1816
|
+
}
|
1817
|
+
|
1818
|
+
function isCancel(value) {
|
1819
|
+
return !!(value && value.__CANCEL__);
|
1820
|
+
}
|
1821
|
+
|
1822
|
+
/**
|
1823
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
1824
|
+
*
|
1825
|
+
* @param {string=} message The message.
|
1826
|
+
* @param {Object=} config The config.
|
1827
|
+
* @param {Object=} request The request.
|
1828
|
+
*
|
1829
|
+
* @returns {CanceledError} The created error.
|
1830
|
+
*/
|
1831
|
+
function CanceledError(message, config, request) {
|
1832
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
1833
|
+
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
1834
|
+
this.name = 'CanceledError';
|
1835
|
+
}
|
1836
|
+
|
1837
|
+
utils.inherits(CanceledError, AxiosError, {
|
1838
|
+
__CANCEL__: true
|
1839
|
+
});
|
1840
|
+
|
1841
|
+
/**
|
1842
|
+
* Resolve or reject a Promise based on response status.
|
1843
|
+
*
|
1844
|
+
* @param {Function} resolve A function that resolves the promise.
|
1845
|
+
* @param {Function} reject A function that rejects the promise.
|
1846
|
+
* @param {object} response The response.
|
1847
|
+
*
|
1848
|
+
* @returns {object} The response.
|
1849
|
+
*/
|
1850
|
+
function settle(resolve, reject, response) {
|
1851
|
+
const validateStatus = response.config.validateStatus;
|
1852
|
+
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
1853
|
+
resolve(response);
|
1854
|
+
} else {
|
1855
|
+
reject(new AxiosError(
|
1856
|
+
'Request failed with status code ' + response.status,
|
1857
|
+
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
1858
|
+
response.config,
|
1859
|
+
response.request,
|
1860
|
+
response
|
1861
|
+
));
|
1862
|
+
}
|
1863
|
+
}
|
1864
|
+
|
1865
|
+
/**
|
1866
|
+
* Determines whether the specified URL is absolute
|
1867
|
+
*
|
1868
|
+
* @param {string} url The URL to test
|
1869
|
+
*
|
1870
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
1871
|
+
*/
|
1872
|
+
function isAbsoluteURL(url) {
|
1873
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
1874
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
1875
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
1876
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
1877
|
+
}
|
1878
|
+
|
1879
|
+
/**
|
1880
|
+
* Creates a new URL by combining the specified URLs
|
1881
|
+
*
|
1882
|
+
* @param {string} baseURL The base URL
|
1883
|
+
* @param {string} relativeURL The relative URL
|
1884
|
+
*
|
1885
|
+
* @returns {string} The combined URL
|
1886
|
+
*/
|
1887
|
+
function combineURLs(baseURL, relativeURL) {
|
1888
|
+
return relativeURL
|
1889
|
+
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
1890
|
+
: baseURL;
|
1891
|
+
}
|
1892
|
+
|
1893
|
+
/**
|
1894
|
+
* Creates a new URL by combining the baseURL with the requestedURL,
|
1895
|
+
* only when the requestedURL is not already an absolute URL.
|
1896
|
+
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
1897
|
+
*
|
1898
|
+
* @param {string} baseURL The base URL
|
1899
|
+
* @param {string} requestedURL Absolute or relative URL to combine
|
1900
|
+
*
|
1901
|
+
* @returns {string} The combined full path
|
1902
|
+
*/
|
1903
|
+
function buildFullPath(baseURL, requestedURL) {
|
1904
|
+
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
1905
|
+
return combineURLs(baseURL, requestedURL);
|
1906
|
+
}
|
1907
|
+
return requestedURL;
|
1908
|
+
}
|
1909
|
+
|
1910
|
+
const VERSION = "1.2.0";
|
1911
|
+
|
1912
|
+
function parseProtocol(url) {
|
1913
|
+
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
1914
|
+
return match && match[1] || '';
|
1915
|
+
}
|
1916
|
+
|
1917
|
+
const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
|
1918
|
+
|
1919
|
+
/**
|
1920
|
+
* Parse data uri to a Buffer or Blob
|
1921
|
+
*
|
1922
|
+
* @param {String} uri
|
1923
|
+
* @param {?Boolean} asBlob
|
1924
|
+
* @param {?Object} options
|
1925
|
+
* @param {?Function} options.Blob
|
1926
|
+
*
|
1927
|
+
* @returns {Buffer|Blob}
|
1928
|
+
*/
|
1929
|
+
function fromDataURI(uri, asBlob, options) {
|
1930
|
+
const _Blob = options && options.Blob || platform.classes.Blob;
|
1931
|
+
const protocol = parseProtocol(uri);
|
1932
|
+
|
1933
|
+
if (asBlob === undefined && _Blob) {
|
1934
|
+
asBlob = true;
|
1935
|
+
}
|
1936
|
+
|
1937
|
+
if (protocol === 'data') {
|
1938
|
+
uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
|
1939
|
+
|
1940
|
+
const match = DATA_URL_PATTERN.exec(uri);
|
1941
|
+
|
1942
|
+
if (!match) {
|
1943
|
+
throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
|
1944
|
+
}
|
1945
|
+
|
1946
|
+
const mime = match[1];
|
1947
|
+
const isBase64 = match[2];
|
1948
|
+
const body = match[3];
|
1949
|
+
const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
|
1693
1950
|
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1951
|
+
if (asBlob) {
|
1952
|
+
if (!_Blob) {
|
1953
|
+
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
1697
1954
|
}
|
1698
|
-
}
|
1699
1955
|
|
1700
|
-
|
1956
|
+
return new _Blob([buffer], {type: mime});
|
1957
|
+
}
|
1701
1958
|
|
1702
|
-
return
|
1959
|
+
return buffer;
|
1703
1960
|
}
|
1704
|
-
});
|
1705
|
-
|
1706
|
-
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
|
1707
1961
|
|
1708
|
-
|
1709
|
-
|
1962
|
+
throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
|
1963
|
+
}
|
1710
1964
|
|
1711
1965
|
/**
|
1712
1966
|
* Throttle decorator
|
@@ -1973,6 +2227,8 @@ class AxiosTransformStream extends stream__default["default"].Transform{
|
|
1973
2227
|
}
|
1974
2228
|
}
|
1975
2229
|
|
2230
|
+
const AxiosTransformStream$1 = AxiosTransformStream;
|
2231
|
+
|
1976
2232
|
const isBrotliSupported = utils.isFunction(zlib__default["default"].createBrotliDecompress);
|
1977
2233
|
|
1978
2234
|
const {http: httpFollow, https: httpsFollow} = followRedirects__default["default"];
|
@@ -2053,8 +2309,10 @@ function setProxy(options, configProxy, location) {
|
|
2053
2309
|
};
|
2054
2310
|
}
|
2055
2311
|
|
2312
|
+
const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process';
|
2313
|
+
|
2056
2314
|
/*eslint consistent-return:0*/
|
2057
|
-
function httpAdapter(config) {
|
2315
|
+
const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
2058
2316
|
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
2059
2317
|
let data = config.data;
|
2060
2318
|
const responseType = config.responseType;
|
@@ -2156,7 +2414,7 @@ function httpAdapter(config) {
|
|
2156
2414
|
data: convertedData,
|
2157
2415
|
status: 200,
|
2158
2416
|
statusText: 'OK',
|
2159
|
-
headers:
|
2417
|
+
headers: new AxiosHeaders$1(),
|
2160
2418
|
config
|
2161
2419
|
});
|
2162
2420
|
}
|
@@ -2169,7 +2427,7 @@ function httpAdapter(config) {
|
|
2169
2427
|
));
|
2170
2428
|
}
|
2171
2429
|
|
2172
|
-
const headers = AxiosHeaders.from(config.headers).normalize();
|
2430
|
+
const headers = AxiosHeaders$1.from(config.headers).normalize();
|
2173
2431
|
|
2174
2432
|
// Set User-Agent (required by some servers)
|
2175
2433
|
// See https://github.com/axios/axios/issues/69
|
@@ -2225,7 +2483,7 @@ function httpAdapter(config) {
|
|
2225
2483
|
data = stream__default["default"].Readable.from(data, {objectMode: false});
|
2226
2484
|
}
|
2227
2485
|
|
2228
|
-
data = stream__default["default"].pipeline([data, new AxiosTransformStream({
|
2486
|
+
data = stream__default["default"].pipeline([data, new AxiosTransformStream$1({
|
2229
2487
|
length: utils.toFiniteNumber(contentLength),
|
2230
2488
|
maxRate: utils.toFiniteNumber(maxUploadRate)
|
2231
2489
|
})], utils.noop);
|
@@ -2324,6 +2582,23 @@ function httpAdapter(config) {
|
|
2324
2582
|
|
2325
2583
|
const streams = [res];
|
2326
2584
|
|
2585
|
+
const responseLength = +res.headers['content-length'];
|
2586
|
+
|
2587
|
+
if (onDownloadProgress) {
|
2588
|
+
const transformStream = new AxiosTransformStream$1({
|
2589
|
+
length: utils.toFiniteNumber(responseLength),
|
2590
|
+
maxRate: utils.toFiniteNumber(maxDownloadRate)
|
2591
|
+
});
|
2592
|
+
|
2593
|
+
onDownloadProgress && transformStream.on('progress', progress => {
|
2594
|
+
onDownloadProgress(Object.assign(progress, {
|
2595
|
+
download: true
|
2596
|
+
}));
|
2597
|
+
});
|
2598
|
+
|
2599
|
+
streams.push(transformStream);
|
2600
|
+
}
|
2601
|
+
|
2327
2602
|
// uncompress the response body transparently if required
|
2328
2603
|
let responseStream = res;
|
2329
2604
|
|
@@ -2334,7 +2609,7 @@ function httpAdapter(config) {
|
|
2334
2609
|
if (config.decompress !== false) {
|
2335
2610
|
// if no content, but headers still say that it is encoded,
|
2336
2611
|
// remove the header not confuse downstream operations
|
2337
|
-
if (
|
2612
|
+
if ((!responseLength || res.statusCode === 204) && res.headers['content-encoding']) {
|
2338
2613
|
delete res.headers['content-encoding'];
|
2339
2614
|
}
|
2340
2615
|
|
@@ -2357,23 +2632,6 @@ function httpAdapter(config) {
|
|
2357
2632
|
}
|
2358
2633
|
}
|
2359
2634
|
|
2360
|
-
if (onDownloadProgress) {
|
2361
|
-
const responseLength = +res.headers['content-length'];
|
2362
|
-
|
2363
|
-
const transformStream = new AxiosTransformStream({
|
2364
|
-
length: utils.toFiniteNumber(responseLength),
|
2365
|
-
maxRate: utils.toFiniteNumber(maxDownloadRate)
|
2366
|
-
});
|
2367
|
-
|
2368
|
-
onDownloadProgress && transformStream.on('progress', progress => {
|
2369
|
-
onDownloadProgress(Object.assign(progress, {
|
2370
|
-
download: true
|
2371
|
-
}));
|
2372
|
-
});
|
2373
|
-
|
2374
|
-
streams.push(transformStream);
|
2375
|
-
}
|
2376
|
-
|
2377
2635
|
responseStream = streams.length > 1 ? stream__default["default"].pipeline(streams, utils.noop) : streams[0];
|
2378
2636
|
|
2379
2637
|
const offListeners = stream__default["default"].finished(responseStream, () => {
|
@@ -2384,7 +2642,7 @@ function httpAdapter(config) {
|
|
2384
2642
|
const response = {
|
2385
2643
|
status: res.statusCode,
|
2386
2644
|
statusText: res.statusMessage,
|
2387
|
-
headers: new AxiosHeaders(res.headers),
|
2645
|
+
headers: new AxiosHeaders$1(res.headers),
|
2388
2646
|
config,
|
2389
2647
|
request: lastRequest
|
2390
2648
|
};
|
@@ -2537,7 +2795,7 @@ function httpAdapter(config) {
|
|
2537
2795
|
req.end(data);
|
2538
2796
|
}
|
2539
2797
|
});
|
2540
|
-
}
|
2798
|
+
};
|
2541
2799
|
|
2542
2800
|
const cookies = platform.isStandardBrowserEnv ?
|
2543
2801
|
|
@@ -2669,7 +2927,8 @@ function progressEventReducer(listener, isDownloadStream) {
|
|
2669
2927
|
progress: total ? (loaded / total) : undefined,
|
2670
2928
|
bytes: progressBytes,
|
2671
2929
|
rate: rate ? rate : undefined,
|
2672
|
-
estimated: rate && total && inRange ? (total - loaded) / rate : undefined
|
2930
|
+
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
2931
|
+
event: e
|
2673
2932
|
};
|
2674
2933
|
|
2675
2934
|
data[isDownloadStream ? 'download' : 'upload'] = true;
|
@@ -2678,10 +2937,12 @@ function progressEventReducer(listener, isDownloadStream) {
|
|
2678
2937
|
};
|
2679
2938
|
}
|
2680
2939
|
|
2681
|
-
|
2940
|
+
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
2941
|
+
|
2942
|
+
const xhrAdapter = isXHRAdapterSupported && function (config) {
|
2682
2943
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
2683
2944
|
let requestData = config.data;
|
2684
|
-
const requestHeaders = AxiosHeaders.from(config.headers).normalize();
|
2945
|
+
const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
|
2685
2946
|
const responseType = config.responseType;
|
2686
2947
|
let onCanceled;
|
2687
2948
|
function done() {
|
@@ -2719,7 +2980,7 @@ function xhrAdapter(config) {
|
|
2719
2980
|
return;
|
2720
2981
|
}
|
2721
2982
|
// Prepare the response
|
2722
|
-
const responseHeaders = AxiosHeaders.from(
|
2983
|
+
const responseHeaders = AxiosHeaders$1.from(
|
2723
2984
|
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
2724
2985
|
);
|
2725
2986
|
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
@@ -2879,238 +3140,63 @@ function xhrAdapter(config) {
|
|
2879
3140
|
// Send the request
|
2880
3141
|
request.send(requestData || null);
|
2881
3142
|
});
|
2882
|
-
}
|
3143
|
+
};
|
2883
3144
|
|
2884
|
-
const
|
3145
|
+
const knownAdapters = {
|
2885
3146
|
http: httpAdapter,
|
2886
3147
|
xhr: xhrAdapter
|
2887
3148
|
};
|
2888
3149
|
|
2889
|
-
|
2890
|
-
|
2891
|
-
if(utils.isString(nameOrAdapter)){
|
2892
|
-
const adapter = adapters[nameOrAdapter];
|
2893
|
-
|
2894
|
-
if (!nameOrAdapter) {
|
2895
|
-
throw Error(
|
2896
|
-
utils.hasOwnProp(nameOrAdapter) ?
|
2897
|
-
`Adapter '${nameOrAdapter}' is not available in the build` :
|
2898
|
-
`Can not resolve adapter '${nameOrAdapter}'`
|
2899
|
-
);
|
2900
|
-
}
|
2901
|
-
|
2902
|
-
return adapter
|
2903
|
-
}
|
2904
|
-
|
2905
|
-
if (!utils.isFunction(nameOrAdapter)) {
|
2906
|
-
throw new TypeError('adapter is not a function');
|
2907
|
-
}
|
2908
|
-
|
2909
|
-
return nameOrAdapter;
|
2910
|
-
},
|
2911
|
-
adapters
|
2912
|
-
};
|
2913
|
-
|
2914
|
-
const DEFAULT_CONTENT_TYPE = {
|
2915
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
2916
|
-
};
|
2917
|
-
|
2918
|
-
/**
|
2919
|
-
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
|
2920
|
-
* adapter
|
2921
|
-
*
|
2922
|
-
* @returns {Function}
|
2923
|
-
*/
|
2924
|
-
function getDefaultAdapter() {
|
2925
|
-
let adapter;
|
2926
|
-
if (typeof XMLHttpRequest !== 'undefined') {
|
2927
|
-
// For browsers use XHR adapter
|
2928
|
-
adapter = adapters$1.getAdapter('xhr');
|
2929
|
-
} else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
|
2930
|
-
// For node use HTTP adapter
|
2931
|
-
adapter = adapters$1.getAdapter('http');
|
2932
|
-
}
|
2933
|
-
return adapter;
|
2934
|
-
}
|
2935
|
-
|
2936
|
-
/**
|
2937
|
-
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
2938
|
-
* of the input
|
2939
|
-
*
|
2940
|
-
* @param {any} rawValue - The value to be stringified.
|
2941
|
-
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
2942
|
-
* @param {Function} encoder - A function that takes a value and returns a string.
|
2943
|
-
*
|
2944
|
-
* @returns {string} A stringified version of the rawValue.
|
2945
|
-
*/
|
2946
|
-
function stringifySafely(rawValue, parser, encoder) {
|
2947
|
-
if (utils.isString(rawValue)) {
|
3150
|
+
utils.forEach(knownAdapters, (fn, value) => {
|
3151
|
+
if(fn) {
|
2948
3152
|
try {
|
2949
|
-
(
|
2950
|
-
return utils.trim(rawValue);
|
3153
|
+
Object.defineProperty(fn, 'name', {value});
|
2951
3154
|
} catch (e) {
|
2952
|
-
|
2953
|
-
throw e;
|
2954
|
-
}
|
3155
|
+
// eslint-disable-next-line no-empty
|
2955
3156
|
}
|
3157
|
+
Object.defineProperty(fn, 'adapterName', {value});
|
2956
3158
|
}
|
3159
|
+
});
|
2957
3160
|
|
2958
|
-
|
2959
|
-
|
2960
|
-
|
2961
|
-
const defaults = {
|
2962
|
-
|
2963
|
-
transitional: transitionalDefaults,
|
2964
|
-
|
2965
|
-
adapter: getDefaultAdapter(),
|
2966
|
-
|
2967
|
-
transformRequest: [function transformRequest(data, headers) {
|
2968
|
-
const contentType = headers.getContentType() || '';
|
2969
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
2970
|
-
const isObjectPayload = utils.isObject(data);
|
2971
|
-
|
2972
|
-
if (isObjectPayload && utils.isHTMLForm(data)) {
|
2973
|
-
data = new FormData(data);
|
2974
|
-
}
|
3161
|
+
const adapters = {
|
3162
|
+
getAdapter: (adapters) => {
|
3163
|
+
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
2975
3164
|
|
2976
|
-
const
|
3165
|
+
const {length} = adapters;
|
3166
|
+
let nameOrAdapter;
|
3167
|
+
let adapter;
|
2977
3168
|
|
2978
|
-
|
2979
|
-
|
2980
|
-
|
3169
|
+
for (let i = 0; i < length; i++) {
|
3170
|
+
nameOrAdapter = adapters[i];
|
3171
|
+
if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
|
3172
|
+
break;
|
2981
3173
|
}
|
2982
|
-
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
2983
3174
|
}
|
2984
3175
|
|
2985
|
-
if (
|
2986
|
-
|
2987
|
-
|
2988
|
-
|
2989
|
-
|
2990
|
-
) {
|
2991
|
-
return data;
|
2992
|
-
}
|
2993
|
-
if (utils.isArrayBufferView(data)) {
|
2994
|
-
return data.buffer;
|
2995
|
-
}
|
2996
|
-
if (utils.isURLSearchParams(data)) {
|
2997
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
2998
|
-
return data.toString();
|
2999
|
-
}
|
3000
|
-
|
3001
|
-
let isFileList;
|
3002
|
-
|
3003
|
-
if (isObjectPayload) {
|
3004
|
-
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
3005
|
-
return toURLEncodedForm(data, this.formSerializer).toString();
|
3006
|
-
}
|
3007
|
-
|
3008
|
-
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
3009
|
-
const _FormData = this.env && this.env.FormData;
|
3010
|
-
|
3011
|
-
return toFormData(
|
3012
|
-
isFileList ? {'files[]': data} : data,
|
3013
|
-
_FormData && new _FormData(),
|
3014
|
-
this.formSerializer
|
3176
|
+
if (!adapter) {
|
3177
|
+
if (adapter === false) {
|
3178
|
+
throw new AxiosError(
|
3179
|
+
`Adapter ${nameOrAdapter} is not supported by the environment`,
|
3180
|
+
'ERR_NOT_SUPPORT'
|
3015
3181
|
);
|
3016
3182
|
}
|
3017
|
-
}
|
3018
3183
|
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3184
|
+
throw new Error(
|
3185
|
+
utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
|
3186
|
+
`Adapter '${nameOrAdapter}' is not available in the build` :
|
3187
|
+
`Unknown adapter '${nameOrAdapter}'`
|
3188
|
+
);
|
3022
3189
|
}
|
3023
3190
|
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
transformResponse: [function transformResponse(data) {
|
3028
|
-
const transitional = this.transitional || defaults.transitional;
|
3029
|
-
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
3030
|
-
const JSONRequested = this.responseType === 'json';
|
3031
|
-
|
3032
|
-
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
3033
|
-
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
3034
|
-
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
3035
|
-
|
3036
|
-
try {
|
3037
|
-
return JSON.parse(data);
|
3038
|
-
} catch (e) {
|
3039
|
-
if (strictJSONParsing) {
|
3040
|
-
if (e.name === 'SyntaxError') {
|
3041
|
-
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
3042
|
-
}
|
3043
|
-
throw e;
|
3044
|
-
}
|
3045
|
-
}
|
3191
|
+
if (!utils.isFunction(adapter)) {
|
3192
|
+
throw new TypeError('adapter is not a function');
|
3046
3193
|
}
|
3047
3194
|
|
3048
|
-
return
|
3049
|
-
}],
|
3050
|
-
|
3051
|
-
/**
|
3052
|
-
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
3053
|
-
* timeout is not created.
|
3054
|
-
*/
|
3055
|
-
timeout: 0,
|
3056
|
-
|
3057
|
-
xsrfCookieName: 'XSRF-TOKEN',
|
3058
|
-
xsrfHeaderName: 'X-XSRF-TOKEN',
|
3059
|
-
|
3060
|
-
maxContentLength: -1,
|
3061
|
-
maxBodyLength: -1,
|
3062
|
-
|
3063
|
-
env: {
|
3064
|
-
FormData: platform.classes.FormData,
|
3065
|
-
Blob: platform.classes.Blob
|
3066
|
-
},
|
3067
|
-
|
3068
|
-
validateStatus: function validateStatus(status) {
|
3069
|
-
return status >= 200 && status < 300;
|
3195
|
+
return adapter;
|
3070
3196
|
},
|
3071
|
-
|
3072
|
-
headers: {
|
3073
|
-
common: {
|
3074
|
-
'Accept': 'application/json, text/plain, */*'
|
3075
|
-
}
|
3076
|
-
}
|
3197
|
+
adapters: knownAdapters
|
3077
3198
|
};
|
3078
3199
|
|
3079
|
-
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
3080
|
-
defaults.headers[method] = {};
|
3081
|
-
});
|
3082
|
-
|
3083
|
-
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
3084
|
-
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
3085
|
-
});
|
3086
|
-
|
3087
|
-
/**
|
3088
|
-
* Transform the data for a request or a response
|
3089
|
-
*
|
3090
|
-
* @param {Array|Function} fns A single function or Array of functions
|
3091
|
-
* @param {?Object} response The response object
|
3092
|
-
*
|
3093
|
-
* @returns {*} The resulting transformed data
|
3094
|
-
*/
|
3095
|
-
function transformData(fns, response) {
|
3096
|
-
const config = this || defaults;
|
3097
|
-
const context = response || config;
|
3098
|
-
const headers = AxiosHeaders.from(context.headers);
|
3099
|
-
let data = context.data;
|
3100
|
-
|
3101
|
-
utils.forEach(fns, function transform(fn) {
|
3102
|
-
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
3103
|
-
});
|
3104
|
-
|
3105
|
-
headers.normalize();
|
3106
|
-
|
3107
|
-
return data;
|
3108
|
-
}
|
3109
|
-
|
3110
|
-
function isCancel(value) {
|
3111
|
-
return !!(value && value.__CANCEL__);
|
3112
|
-
}
|
3113
|
-
|
3114
3200
|
/**
|
3115
3201
|
* Throws a `CanceledError` if cancellation has been requested.
|
3116
3202
|
*
|
@@ -3138,7 +3224,7 @@ function throwIfCancellationRequested(config) {
|
|
3138
3224
|
function dispatchRequest(config) {
|
3139
3225
|
throwIfCancellationRequested(config);
|
3140
3226
|
|
3141
|
-
config.headers = AxiosHeaders.from(config.headers);
|
3227
|
+
config.headers = AxiosHeaders$1.from(config.headers);
|
3142
3228
|
|
3143
3229
|
// Transform request data
|
3144
3230
|
config.data = transformData.call(
|
@@ -3146,7 +3232,11 @@ function dispatchRequest(config) {
|
|
3146
3232
|
config.transformRequest
|
3147
3233
|
);
|
3148
3234
|
|
3149
|
-
|
3235
|
+
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
3236
|
+
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
3237
|
+
}
|
3238
|
+
|
3239
|
+
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
3150
3240
|
|
3151
3241
|
return adapter(config).then(function onAdapterResolution(response) {
|
3152
3242
|
throwIfCancellationRequested(config);
|
@@ -3158,7 +3248,7 @@ function dispatchRequest(config) {
|
|
3158
3248
|
response
|
3159
3249
|
);
|
3160
3250
|
|
3161
|
-
response.headers = AxiosHeaders.from(response.headers);
|
3251
|
+
response.headers = AxiosHeaders$1.from(response.headers);
|
3162
3252
|
|
3163
3253
|
return response;
|
3164
3254
|
}, function onAdapterRejection(reason) {
|
@@ -3172,7 +3262,7 @@ function dispatchRequest(config) {
|
|
3172
3262
|
config.transformResponse,
|
3173
3263
|
reason.response
|
3174
3264
|
);
|
3175
|
-
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
3265
|
+
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
3176
3266
|
}
|
3177
3267
|
}
|
3178
3268
|
|
@@ -3180,6 +3270,8 @@ function dispatchRequest(config) {
|
|
3180
3270
|
});
|
3181
3271
|
}
|
3182
3272
|
|
3273
|
+
const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
|
3274
|
+
|
3183
3275
|
/**
|
3184
3276
|
* Config-specific merge-function which creates a new config-object
|
3185
3277
|
* by merging two configuration objects together.
|
@@ -3194,9 +3286,9 @@ function mergeConfig(config1, config2) {
|
|
3194
3286
|
config2 = config2 || {};
|
3195
3287
|
const config = {};
|
3196
3288
|
|
3197
|
-
function getMergedValue(target, source) {
|
3289
|
+
function getMergedValue(target, source, caseless) {
|
3198
3290
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
3199
|
-
return utils.merge(target, source);
|
3291
|
+
return utils.merge.call({caseless}, target, source);
|
3200
3292
|
} else if (utils.isPlainObject(source)) {
|
3201
3293
|
return utils.merge({}, source);
|
3202
3294
|
} else if (utils.isArray(source)) {
|
@@ -3206,72 +3298,73 @@ function mergeConfig(config1, config2) {
|
|
3206
3298
|
}
|
3207
3299
|
|
3208
3300
|
// eslint-disable-next-line consistent-return
|
3209
|
-
function mergeDeepProperties(
|
3210
|
-
if (!utils.isUndefined(
|
3211
|
-
return getMergedValue(
|
3212
|
-
} else if (!utils.isUndefined(
|
3213
|
-
return getMergedValue(undefined,
|
3301
|
+
function mergeDeepProperties(a, b, caseless) {
|
3302
|
+
if (!utils.isUndefined(b)) {
|
3303
|
+
return getMergedValue(a, b, caseless);
|
3304
|
+
} else if (!utils.isUndefined(a)) {
|
3305
|
+
return getMergedValue(undefined, a, caseless);
|
3214
3306
|
}
|
3215
3307
|
}
|
3216
3308
|
|
3217
3309
|
// eslint-disable-next-line consistent-return
|
3218
|
-
function valueFromConfig2(
|
3219
|
-
if (!utils.isUndefined(
|
3220
|
-
return getMergedValue(undefined,
|
3310
|
+
function valueFromConfig2(a, b) {
|
3311
|
+
if (!utils.isUndefined(b)) {
|
3312
|
+
return getMergedValue(undefined, b);
|
3221
3313
|
}
|
3222
3314
|
}
|
3223
3315
|
|
3224
3316
|
// eslint-disable-next-line consistent-return
|
3225
|
-
function defaultToConfig2(
|
3226
|
-
if (!utils.isUndefined(
|
3227
|
-
return getMergedValue(undefined,
|
3228
|
-
} else if (!utils.isUndefined(
|
3229
|
-
return getMergedValue(undefined,
|
3317
|
+
function defaultToConfig2(a, b) {
|
3318
|
+
if (!utils.isUndefined(b)) {
|
3319
|
+
return getMergedValue(undefined, b);
|
3320
|
+
} else if (!utils.isUndefined(a)) {
|
3321
|
+
return getMergedValue(undefined, a);
|
3230
3322
|
}
|
3231
3323
|
}
|
3232
3324
|
|
3233
3325
|
// eslint-disable-next-line consistent-return
|
3234
|
-
function mergeDirectKeys(prop) {
|
3326
|
+
function mergeDirectKeys(a, b, prop) {
|
3235
3327
|
if (prop in config2) {
|
3236
|
-
return getMergedValue(
|
3328
|
+
return getMergedValue(a, b);
|
3237
3329
|
} else if (prop in config1) {
|
3238
|
-
return getMergedValue(undefined,
|
3330
|
+
return getMergedValue(undefined, a);
|
3239
3331
|
}
|
3240
3332
|
}
|
3241
3333
|
|
3242
3334
|
const mergeMap = {
|
3243
|
-
|
3244
|
-
|
3245
|
-
|
3246
|
-
|
3247
|
-
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3253
|
-
|
3254
|
-
|
3255
|
-
|
3256
|
-
|
3257
|
-
|
3258
|
-
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3269
|
-
|
3335
|
+
url: valueFromConfig2,
|
3336
|
+
method: valueFromConfig2,
|
3337
|
+
data: valueFromConfig2,
|
3338
|
+
baseURL: defaultToConfig2,
|
3339
|
+
transformRequest: defaultToConfig2,
|
3340
|
+
transformResponse: defaultToConfig2,
|
3341
|
+
paramsSerializer: defaultToConfig2,
|
3342
|
+
timeout: defaultToConfig2,
|
3343
|
+
timeoutMessage: defaultToConfig2,
|
3344
|
+
withCredentials: defaultToConfig2,
|
3345
|
+
adapter: defaultToConfig2,
|
3346
|
+
responseType: defaultToConfig2,
|
3347
|
+
xsrfCookieName: defaultToConfig2,
|
3348
|
+
xsrfHeaderName: defaultToConfig2,
|
3349
|
+
onUploadProgress: defaultToConfig2,
|
3350
|
+
onDownloadProgress: defaultToConfig2,
|
3351
|
+
decompress: defaultToConfig2,
|
3352
|
+
maxContentLength: defaultToConfig2,
|
3353
|
+
maxBodyLength: defaultToConfig2,
|
3354
|
+
beforeRedirect: defaultToConfig2,
|
3355
|
+
transport: defaultToConfig2,
|
3356
|
+
httpAgent: defaultToConfig2,
|
3357
|
+
httpsAgent: defaultToConfig2,
|
3358
|
+
cancelToken: defaultToConfig2,
|
3359
|
+
socketPath: defaultToConfig2,
|
3360
|
+
responseEncoding: defaultToConfig2,
|
3361
|
+
validateStatus: mergeDirectKeys,
|
3362
|
+
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
3270
3363
|
};
|
3271
3364
|
|
3272
3365
|
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
3273
3366
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
3274
|
-
const configValue = merge(prop);
|
3367
|
+
const configValue = merge(config1[prop], config2[prop], prop);
|
3275
3368
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
3276
3369
|
});
|
3277
3370
|
|
@@ -3378,8 +3471,8 @@ class Axios {
|
|
3378
3471
|
constructor(instanceConfig) {
|
3379
3472
|
this.defaults = instanceConfig;
|
3380
3473
|
this.interceptors = {
|
3381
|
-
request: new InterceptorManager(),
|
3382
|
-
response: new InterceptorManager()
|
3474
|
+
request: new InterceptorManager$1(),
|
3475
|
+
response: new InterceptorManager$1()
|
3383
3476
|
};
|
3384
3477
|
}
|
3385
3478
|
|
@@ -3403,7 +3496,7 @@ class Axios {
|
|
3403
3496
|
|
3404
3497
|
config = mergeConfig(this.defaults, config);
|
3405
3498
|
|
3406
|
-
const {transitional, paramsSerializer} = config;
|
3499
|
+
const {transitional, paramsSerializer, headers} = config;
|
3407
3500
|
|
3408
3501
|
if (transitional !== undefined) {
|
3409
3502
|
validator.assertOptions(transitional, {
|
@@ -3423,20 +3516,22 @@ class Axios {
|
|
3423
3516
|
// Set config.method
|
3424
3517
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
3425
3518
|
|
3519
|
+
let contextHeaders;
|
3520
|
+
|
3426
3521
|
// Flatten headers
|
3427
|
-
|
3428
|
-
|
3429
|
-
|
3522
|
+
contextHeaders = headers && utils.merge(
|
3523
|
+
headers.common,
|
3524
|
+
headers[config.method]
|
3430
3525
|
);
|
3431
3526
|
|
3432
|
-
|
3527
|
+
contextHeaders && utils.forEach(
|
3433
3528
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
3434
|
-
|
3435
|
-
delete
|
3529
|
+
(method) => {
|
3530
|
+
delete headers[method];
|
3436
3531
|
}
|
3437
3532
|
);
|
3438
3533
|
|
3439
|
-
config.headers =
|
3534
|
+
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
3440
3535
|
|
3441
3536
|
// filter out skipped interceptors
|
3442
3537
|
const requestInterceptorChain = [];
|
@@ -3548,6 +3643,8 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
3548
3643
|
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
3549
3644
|
});
|
3550
3645
|
|
3646
|
+
const Axios$1 = Axios;
|
3647
|
+
|
3551
3648
|
/**
|
3552
3649
|
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
3553
3650
|
*
|
@@ -3664,6 +3761,8 @@ class CancelToken {
|
|
3664
3761
|
}
|
3665
3762
|
}
|
3666
3763
|
|
3764
|
+
const CancelToken$1 = CancelToken;
|
3765
|
+
|
3667
3766
|
/**
|
3668
3767
|
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
3669
3768
|
*
|
@@ -3710,11 +3809,11 @@ function isAxiosError(payload) {
|
|
3710
3809
|
* @returns {Axios} A new instance of Axios
|
3711
3810
|
*/
|
3712
3811
|
function createInstance(defaultConfig) {
|
3713
|
-
const context = new Axios(defaultConfig);
|
3714
|
-
const instance = bind(Axios.prototype.request, context);
|
3812
|
+
const context = new Axios$1(defaultConfig);
|
3813
|
+
const instance = bind(Axios$1.prototype.request, context);
|
3715
3814
|
|
3716
3815
|
// Copy axios.prototype to instance
|
3717
|
-
utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});
|
3816
|
+
utils.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
3718
3817
|
|
3719
3818
|
// Copy context to instance
|
3720
3819
|
utils.extend(instance, context, null, {allOwnKeys: true});
|
@@ -3728,14 +3827,14 @@ function createInstance(defaultConfig) {
|
|
3728
3827
|
}
|
3729
3828
|
|
3730
3829
|
// Create the default instance to be exported
|
3731
|
-
const axios = createInstance(defaults);
|
3830
|
+
const axios = createInstance(defaults$1);
|
3732
3831
|
|
3733
3832
|
// Expose Axios class to allow class inheritance
|
3734
|
-
axios.Axios = Axios;
|
3833
|
+
axios.Axios = Axios$1;
|
3735
3834
|
|
3736
3835
|
// Expose Cancel & CancelToken
|
3737
3836
|
axios.CanceledError = CanceledError;
|
3738
|
-
axios.CancelToken = CancelToken;
|
3837
|
+
axios.CancelToken = CancelToken$1;
|
3739
3838
|
axios.isCancel = isCancel;
|
3740
3839
|
axios.VERSION = VERSION;
|
3741
3840
|
axios.toFormData = toFormData;
|
@@ -3756,9 +3855,11 @@ axios.spread = spread;
|
|
3756
3855
|
// Expose isAxiosError
|
3757
3856
|
axios.isAxiosError = isAxiosError;
|
3758
3857
|
|
3759
|
-
axios.
|
3760
|
-
|
3761
|
-
|
3858
|
+
axios.AxiosHeaders = AxiosHeaders$1;
|
3859
|
+
|
3860
|
+
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
3861
|
+
|
3862
|
+
axios.default = axios;
|
3762
3863
|
|
3763
3864
|
module.exports = axios;
|
3764
3865
|
//# sourceMappingURL=axios.cjs.map
|