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/dist/esm/axios.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.2.
|
1
|
+
// Axios v1.2.1 Copyright (c) 2022 Matt Zabriskie and contributors
|
2
2
|
function bind(fn, thisArg) {
|
3
3
|
return function wrap() {
|
4
4
|
return fn.apply(thisArg, arguments);
|
@@ -595,6 +595,37 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
595
595
|
return Number.isFinite(value) ? value : defaultValue;
|
596
596
|
};
|
597
597
|
|
598
|
+
const toJSONObject = (obj) => {
|
599
|
+
const stack = new Array(10);
|
600
|
+
|
601
|
+
const visit = (source, i) => {
|
602
|
+
|
603
|
+
if (isObject(source)) {
|
604
|
+
if (stack.indexOf(source) >= 0) {
|
605
|
+
return;
|
606
|
+
}
|
607
|
+
|
608
|
+
if(!('toJSON' in source)) {
|
609
|
+
stack[i] = source;
|
610
|
+
const target = isArray(source) ? [] : {};
|
611
|
+
|
612
|
+
forEach(source, (value, key) => {
|
613
|
+
const reducedValue = visit(value, i + 1);
|
614
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
615
|
+
});
|
616
|
+
|
617
|
+
stack[i] = undefined;
|
618
|
+
|
619
|
+
return target;
|
620
|
+
}
|
621
|
+
}
|
622
|
+
|
623
|
+
return source;
|
624
|
+
};
|
625
|
+
|
626
|
+
return visit(obj, 0);
|
627
|
+
};
|
628
|
+
|
598
629
|
const utils = {
|
599
630
|
isArray,
|
600
631
|
isArrayBuffer,
|
@@ -640,7 +671,8 @@ const utils = {
|
|
640
671
|
toFiniteNumber,
|
641
672
|
findKey,
|
642
673
|
global: _global,
|
643
|
-
isContextDefined
|
674
|
+
isContextDefined,
|
675
|
+
toJSONObject
|
644
676
|
};
|
645
677
|
|
646
678
|
/**
|
@@ -686,7 +718,7 @@ utils.inherits(AxiosError$1, Error, {
|
|
686
718
|
columnNumber: this.columnNumber,
|
687
719
|
stack: this.stack,
|
688
720
|
// Axios
|
689
|
-
config: this.config,
|
721
|
+
config: utils.toJSONObject(this.config),
|
690
722
|
code: this.code,
|
691
723
|
status: this.response && this.response.status ? this.response.status : null
|
692
724
|
};
|
@@ -1185,6 +1217,24 @@ const isStandardBrowserEnv = (() => {
|
|
1185
1217
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
1186
1218
|
})();
|
1187
1219
|
|
1220
|
+
/**
|
1221
|
+
* Determine if we're running in a standard browser webWorker environment
|
1222
|
+
*
|
1223
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
1224
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
1225
|
+
* filtered out due to its judgment standard
|
1226
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
1227
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
1228
|
+
*/
|
1229
|
+
const isStandardBrowserWebWorkerEnv = (() => {
|
1230
|
+
return (
|
1231
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
1232
|
+
self instanceof WorkerGlobalScope &&
|
1233
|
+
typeof self.importScripts === 'function'
|
1234
|
+
);
|
1235
|
+
})();
|
1236
|
+
|
1237
|
+
|
1188
1238
|
const platform = {
|
1189
1239
|
isBrowser: true,
|
1190
1240
|
classes: {
|
@@ -1193,6 +1243,7 @@ const platform = {
|
|
1193
1243
|
Blob
|
1194
1244
|
},
|
1195
1245
|
isStandardBrowserEnv,
|
1246
|
+
isStandardBrowserWebWorkerEnv,
|
1196
1247
|
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
1197
1248
|
};
|
1198
1249
|
|
@@ -1296,209 +1347,162 @@ function formDataToJSON(formData) {
|
|
1296
1347
|
return null;
|
1297
1348
|
}
|
1298
1349
|
|
1350
|
+
const DEFAULT_CONTENT_TYPE = {
|
1351
|
+
'Content-Type': undefined
|
1352
|
+
};
|
1353
|
+
|
1299
1354
|
/**
|
1300
|
-
*
|
1355
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
1356
|
+
* of the input
|
1301
1357
|
*
|
1302
|
-
* @param {
|
1303
|
-
* @param {Function}
|
1304
|
-
* @param {
|
1358
|
+
* @param {any} rawValue - The value to be stringified.
|
1359
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
1360
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
1305
1361
|
*
|
1306
|
-
* @returns {
|
1362
|
+
* @returns {string} A stringified version of the rawValue.
|
1307
1363
|
*/
|
1308
|
-
function
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
response
|
1319
|
-
));
|
1364
|
+
function stringifySafely(rawValue, parser, encoder) {
|
1365
|
+
if (utils.isString(rawValue)) {
|
1366
|
+
try {
|
1367
|
+
(parser || JSON.parse)(rawValue);
|
1368
|
+
return utils.trim(rawValue);
|
1369
|
+
} catch (e) {
|
1370
|
+
if (e.name !== 'SyntaxError') {
|
1371
|
+
throw e;
|
1372
|
+
}
|
1373
|
+
}
|
1320
1374
|
}
|
1375
|
+
|
1376
|
+
return (encoder || JSON.stringify)(rawValue);
|
1321
1377
|
}
|
1322
1378
|
|
1323
|
-
const
|
1379
|
+
const defaults = {
|
1324
1380
|
|
1325
|
-
|
1326
|
-
(function standardBrowserEnv() {
|
1327
|
-
return {
|
1328
|
-
write: function write(name, value, expires, path, domain, secure) {
|
1329
|
-
const cookie = [];
|
1330
|
-
cookie.push(name + '=' + encodeURIComponent(value));
|
1381
|
+
transitional: transitionalDefaults,
|
1331
1382
|
|
1332
|
-
|
1333
|
-
cookie.push('expires=' + new Date(expires).toGMTString());
|
1334
|
-
}
|
1383
|
+
adapter: ['xhr', 'http'],
|
1335
1384
|
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1385
|
+
transformRequest: [function transformRequest(data, headers) {
|
1386
|
+
const contentType = headers.getContentType() || '';
|
1387
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
1388
|
+
const isObjectPayload = utils.isObject(data);
|
1339
1389
|
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1390
|
+
if (isObjectPayload && utils.isHTMLForm(data)) {
|
1391
|
+
data = new FormData(data);
|
1392
|
+
}
|
1343
1393
|
|
1344
|
-
|
1345
|
-
cookie.push('secure');
|
1346
|
-
}
|
1394
|
+
const isFormData = utils.isFormData(data);
|
1347
1395
|
|
1348
|
-
|
1349
|
-
|
1396
|
+
if (isFormData) {
|
1397
|
+
if (!hasJSONContentType) {
|
1398
|
+
return data;
|
1399
|
+
}
|
1400
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
1401
|
+
}
|
1350
1402
|
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1403
|
+
if (utils.isArrayBuffer(data) ||
|
1404
|
+
utils.isBuffer(data) ||
|
1405
|
+
utils.isStream(data) ||
|
1406
|
+
utils.isFile(data) ||
|
1407
|
+
utils.isBlob(data)
|
1408
|
+
) {
|
1409
|
+
return data;
|
1410
|
+
}
|
1411
|
+
if (utils.isArrayBufferView(data)) {
|
1412
|
+
return data.buffer;
|
1413
|
+
}
|
1414
|
+
if (utils.isURLSearchParams(data)) {
|
1415
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
1416
|
+
return data.toString();
|
1417
|
+
}
|
1355
1418
|
|
1356
|
-
|
1357
|
-
this.write(name, '', Date.now() - 86400000);
|
1358
|
-
}
|
1359
|
-
};
|
1360
|
-
})() :
|
1419
|
+
let isFileList;
|
1361
1420
|
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
read: function read() { return null; },
|
1367
|
-
remove: function remove() {}
|
1368
|
-
};
|
1369
|
-
})();
|
1421
|
+
if (isObjectPayload) {
|
1422
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
1423
|
+
return toURLEncodedForm(data, this.formSerializer).toString();
|
1424
|
+
}
|
1370
1425
|
|
1371
|
-
|
1372
|
-
|
1373
|
-
*
|
1374
|
-
* @param {string} url The URL to test
|
1375
|
-
*
|
1376
|
-
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
1377
|
-
*/
|
1378
|
-
function isAbsoluteURL(url) {
|
1379
|
-
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
1380
|
-
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
1381
|
-
// by any combination of letters, digits, plus, period, or hyphen.
|
1382
|
-
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
1383
|
-
}
|
1426
|
+
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
1427
|
+
const _FormData = this.env && this.env.FormData;
|
1384
1428
|
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
*/
|
1393
|
-
function combineURLs(baseURL, relativeURL) {
|
1394
|
-
return relativeURL
|
1395
|
-
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
1396
|
-
: baseURL;
|
1397
|
-
}
|
1429
|
+
return toFormData$1(
|
1430
|
+
isFileList ? {'files[]': data} : data,
|
1431
|
+
_FormData && new _FormData(),
|
1432
|
+
this.formSerializer
|
1433
|
+
);
|
1434
|
+
}
|
1435
|
+
}
|
1398
1436
|
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
*
|
1404
|
-
* @param {string} baseURL The base URL
|
1405
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
1406
|
-
*
|
1407
|
-
* @returns {string} The combined full path
|
1408
|
-
*/
|
1409
|
-
function buildFullPath(baseURL, requestedURL) {
|
1410
|
-
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
1411
|
-
return combineURLs(baseURL, requestedURL);
|
1412
|
-
}
|
1413
|
-
return requestedURL;
|
1414
|
-
}
|
1437
|
+
if (isObjectPayload || hasJSONContentType ) {
|
1438
|
+
headers.setContentType('application/json', false);
|
1439
|
+
return stringifySafely(data);
|
1440
|
+
}
|
1415
1441
|
|
1416
|
-
|
1442
|
+
return data;
|
1443
|
+
}],
|
1417
1444
|
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
const
|
1422
|
-
const urlParsingNode = document.createElement('a');
|
1423
|
-
let originURL;
|
1445
|
+
transformResponse: [function transformResponse(data) {
|
1446
|
+
const transitional = this.transitional || defaults.transitional;
|
1447
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
1448
|
+
const JSONRequested = this.responseType === 'json';
|
1424
1449
|
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
* @param {String} url The URL to be parsed
|
1429
|
-
* @returns {Object}
|
1430
|
-
*/
|
1431
|
-
function resolveURL(url) {
|
1432
|
-
let href = url;
|
1450
|
+
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
1451
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
1452
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
1433
1453
|
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1454
|
+
try {
|
1455
|
+
return JSON.parse(data);
|
1456
|
+
} catch (e) {
|
1457
|
+
if (strictJSONParsing) {
|
1458
|
+
if (e.name === 'SyntaxError') {
|
1459
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
1460
|
+
}
|
1461
|
+
throw e;
|
1462
|
+
}
|
1438
1463
|
}
|
1464
|
+
}
|
1439
1465
|
|
1440
|
-
|
1466
|
+
return data;
|
1467
|
+
}],
|
1441
1468
|
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
1448
|
-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
1449
|
-
hostname: urlParsingNode.hostname,
|
1450
|
-
port: urlParsingNode.port,
|
1451
|
-
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
1452
|
-
urlParsingNode.pathname :
|
1453
|
-
'/' + urlParsingNode.pathname
|
1454
|
-
};
|
1455
|
-
}
|
1469
|
+
/**
|
1470
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
1471
|
+
* timeout is not created.
|
1472
|
+
*/
|
1473
|
+
timeout: 0,
|
1456
1474
|
|
1457
|
-
|
1475
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
1476
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
1458
1477
|
|
1459
|
-
|
1460
|
-
|
1461
|
-
*
|
1462
|
-
* @param {String} requestURL The URL to test
|
1463
|
-
* @returns {boolean} True if URL shares the same origin, otherwise false
|
1464
|
-
*/
|
1465
|
-
return function isURLSameOrigin(requestURL) {
|
1466
|
-
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
1467
|
-
return (parsed.protocol === originURL.protocol &&
|
1468
|
-
parsed.host === originURL.host);
|
1469
|
-
};
|
1470
|
-
})() :
|
1478
|
+
maxContentLength: -1,
|
1479
|
+
maxBodyLength: -1,
|
1471
1480
|
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
};
|
1477
|
-
})();
|
1481
|
+
env: {
|
1482
|
+
FormData: platform.classes.FormData,
|
1483
|
+
Blob: platform.classes.Blob
|
1484
|
+
},
|
1478
1485
|
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
* @param {string=} message The message.
|
1483
|
-
* @param {Object=} config The config.
|
1484
|
-
* @param {Object=} request The request.
|
1485
|
-
*
|
1486
|
-
* @returns {CanceledError} The created error.
|
1487
|
-
*/
|
1488
|
-
function CanceledError$1(message, config, request) {
|
1489
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
1490
|
-
AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
1491
|
-
this.name = 'CanceledError';
|
1492
|
-
}
|
1486
|
+
validateStatus: function validateStatus(status) {
|
1487
|
+
return status >= 200 && status < 300;
|
1488
|
+
},
|
1493
1489
|
|
1494
|
-
|
1495
|
-
|
1490
|
+
headers: {
|
1491
|
+
common: {
|
1492
|
+
'Accept': 'application/json, text/plain, */*'
|
1493
|
+
}
|
1494
|
+
}
|
1495
|
+
};
|
1496
|
+
|
1497
|
+
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
1498
|
+
defaults.headers[method] = {};
|
1496
1499
|
});
|
1497
1500
|
|
1498
|
-
function
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1501
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
1502
|
+
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
1503
|
+
});
|
1504
|
+
|
1505
|
+
const defaults$1 = defaults;
|
1502
1506
|
|
1503
1507
|
// RawAxiosHeaders whose duplicates are ignored by node
|
1504
1508
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
@@ -1797,30 +1801,264 @@ class AxiosHeaders$1 {
|
|
1797
1801
|
accessors: {}
|
1798
1802
|
});
|
1799
1803
|
|
1800
|
-
const accessors = internals.accessors;
|
1801
|
-
const prototype = this.prototype;
|
1804
|
+
const accessors = internals.accessors;
|
1805
|
+
const prototype = this.prototype;
|
1806
|
+
|
1807
|
+
function defineAccessor(_header) {
|
1808
|
+
const lHeader = normalizeHeader(_header);
|
1809
|
+
|
1810
|
+
if (!accessors[lHeader]) {
|
1811
|
+
buildAccessors(prototype, _header);
|
1812
|
+
accessors[lHeader] = true;
|
1813
|
+
}
|
1814
|
+
}
|
1815
|
+
|
1816
|
+
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
1817
|
+
|
1818
|
+
return this;
|
1819
|
+
}
|
1820
|
+
}
|
1821
|
+
|
1822
|
+
AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
|
1823
|
+
|
1824
|
+
utils.freezeMethods(AxiosHeaders$1.prototype);
|
1825
|
+
utils.freezeMethods(AxiosHeaders$1);
|
1826
|
+
|
1827
|
+
const AxiosHeaders$2 = AxiosHeaders$1;
|
1828
|
+
|
1829
|
+
/**
|
1830
|
+
* Transform the data for a request or a response
|
1831
|
+
*
|
1832
|
+
* @param {Array|Function} fns A single function or Array of functions
|
1833
|
+
* @param {?Object} response The response object
|
1834
|
+
*
|
1835
|
+
* @returns {*} The resulting transformed data
|
1836
|
+
*/
|
1837
|
+
function transformData(fns, response) {
|
1838
|
+
const config = this || defaults$1;
|
1839
|
+
const context = response || config;
|
1840
|
+
const headers = AxiosHeaders$2.from(context.headers);
|
1841
|
+
let data = context.data;
|
1842
|
+
|
1843
|
+
utils.forEach(fns, function transform(fn) {
|
1844
|
+
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
1845
|
+
});
|
1846
|
+
|
1847
|
+
headers.normalize();
|
1848
|
+
|
1849
|
+
return data;
|
1850
|
+
}
|
1851
|
+
|
1852
|
+
function isCancel$1(value) {
|
1853
|
+
return !!(value && value.__CANCEL__);
|
1854
|
+
}
|
1855
|
+
|
1856
|
+
/**
|
1857
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
1858
|
+
*
|
1859
|
+
* @param {string=} message The message.
|
1860
|
+
* @param {Object=} config The config.
|
1861
|
+
* @param {Object=} request The request.
|
1862
|
+
*
|
1863
|
+
* @returns {CanceledError} The created error.
|
1864
|
+
*/
|
1865
|
+
function CanceledError$1(message, config, request) {
|
1866
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
1867
|
+
AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
1868
|
+
this.name = 'CanceledError';
|
1869
|
+
}
|
1870
|
+
|
1871
|
+
utils.inherits(CanceledError$1, AxiosError$1, {
|
1872
|
+
__CANCEL__: true
|
1873
|
+
});
|
1874
|
+
|
1875
|
+
// eslint-disable-next-line strict
|
1876
|
+
const httpAdapter = null;
|
1877
|
+
|
1878
|
+
/**
|
1879
|
+
* Resolve or reject a Promise based on response status.
|
1880
|
+
*
|
1881
|
+
* @param {Function} resolve A function that resolves the promise.
|
1882
|
+
* @param {Function} reject A function that rejects the promise.
|
1883
|
+
* @param {object} response The response.
|
1884
|
+
*
|
1885
|
+
* @returns {object} The response.
|
1886
|
+
*/
|
1887
|
+
function settle(resolve, reject, response) {
|
1888
|
+
const validateStatus = response.config.validateStatus;
|
1889
|
+
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
1890
|
+
resolve(response);
|
1891
|
+
} else {
|
1892
|
+
reject(new AxiosError$1(
|
1893
|
+
'Request failed with status code ' + response.status,
|
1894
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
1895
|
+
response.config,
|
1896
|
+
response.request,
|
1897
|
+
response
|
1898
|
+
));
|
1899
|
+
}
|
1900
|
+
}
|
1901
|
+
|
1902
|
+
const cookies = platform.isStandardBrowserEnv ?
|
1903
|
+
|
1904
|
+
// Standard browser envs support document.cookie
|
1905
|
+
(function standardBrowserEnv() {
|
1906
|
+
return {
|
1907
|
+
write: function write(name, value, expires, path, domain, secure) {
|
1908
|
+
const cookie = [];
|
1909
|
+
cookie.push(name + '=' + encodeURIComponent(value));
|
1910
|
+
|
1911
|
+
if (utils.isNumber(expires)) {
|
1912
|
+
cookie.push('expires=' + new Date(expires).toGMTString());
|
1913
|
+
}
|
1914
|
+
|
1915
|
+
if (utils.isString(path)) {
|
1916
|
+
cookie.push('path=' + path);
|
1917
|
+
}
|
1918
|
+
|
1919
|
+
if (utils.isString(domain)) {
|
1920
|
+
cookie.push('domain=' + domain);
|
1921
|
+
}
|
1922
|
+
|
1923
|
+
if (secure === true) {
|
1924
|
+
cookie.push('secure');
|
1925
|
+
}
|
1926
|
+
|
1927
|
+
document.cookie = cookie.join('; ');
|
1928
|
+
},
|
1929
|
+
|
1930
|
+
read: function read(name) {
|
1931
|
+
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
1932
|
+
return (match ? decodeURIComponent(match[3]) : null);
|
1933
|
+
},
|
1934
|
+
|
1935
|
+
remove: function remove(name) {
|
1936
|
+
this.write(name, '', Date.now() - 86400000);
|
1937
|
+
}
|
1938
|
+
};
|
1939
|
+
})() :
|
1940
|
+
|
1941
|
+
// Non standard browser env (web workers, react-native) lack needed support.
|
1942
|
+
(function nonStandardBrowserEnv() {
|
1943
|
+
return {
|
1944
|
+
write: function write() {},
|
1945
|
+
read: function read() { return null; },
|
1946
|
+
remove: function remove() {}
|
1947
|
+
};
|
1948
|
+
})();
|
1949
|
+
|
1950
|
+
/**
|
1951
|
+
* Determines whether the specified URL is absolute
|
1952
|
+
*
|
1953
|
+
* @param {string} url The URL to test
|
1954
|
+
*
|
1955
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
1956
|
+
*/
|
1957
|
+
function isAbsoluteURL(url) {
|
1958
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
1959
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
1960
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
1961
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
1962
|
+
}
|
1963
|
+
|
1964
|
+
/**
|
1965
|
+
* Creates a new URL by combining the specified URLs
|
1966
|
+
*
|
1967
|
+
* @param {string} baseURL The base URL
|
1968
|
+
* @param {string} relativeURL The relative URL
|
1969
|
+
*
|
1970
|
+
* @returns {string} The combined URL
|
1971
|
+
*/
|
1972
|
+
function combineURLs(baseURL, relativeURL) {
|
1973
|
+
return relativeURL
|
1974
|
+
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
1975
|
+
: baseURL;
|
1976
|
+
}
|
1977
|
+
|
1978
|
+
/**
|
1979
|
+
* Creates a new URL by combining the baseURL with the requestedURL,
|
1980
|
+
* only when the requestedURL is not already an absolute URL.
|
1981
|
+
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
1982
|
+
*
|
1983
|
+
* @param {string} baseURL The base URL
|
1984
|
+
* @param {string} requestedURL Absolute or relative URL to combine
|
1985
|
+
*
|
1986
|
+
* @returns {string} The combined full path
|
1987
|
+
*/
|
1988
|
+
function buildFullPath(baseURL, requestedURL) {
|
1989
|
+
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
1990
|
+
return combineURLs(baseURL, requestedURL);
|
1991
|
+
}
|
1992
|
+
return requestedURL;
|
1993
|
+
}
|
1994
|
+
|
1995
|
+
const isURLSameOrigin = platform.isStandardBrowserEnv ?
|
1996
|
+
|
1997
|
+
// Standard browser envs have full support of the APIs needed to test
|
1998
|
+
// whether the request URL is of the same origin as current location.
|
1999
|
+
(function standardBrowserEnv() {
|
2000
|
+
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
2001
|
+
const urlParsingNode = document.createElement('a');
|
2002
|
+
let originURL;
|
2003
|
+
|
2004
|
+
/**
|
2005
|
+
* Parse a URL to discover it's components
|
2006
|
+
*
|
2007
|
+
* @param {String} url The URL to be parsed
|
2008
|
+
* @returns {Object}
|
2009
|
+
*/
|
2010
|
+
function resolveURL(url) {
|
2011
|
+
let href = url;
|
2012
|
+
|
2013
|
+
if (msie) {
|
2014
|
+
// IE needs attribute set twice to normalize properties
|
2015
|
+
urlParsingNode.setAttribute('href', href);
|
2016
|
+
href = urlParsingNode.href;
|
2017
|
+
}
|
1802
2018
|
|
1803
|
-
|
1804
|
-
const lHeader = normalizeHeader(_header);
|
2019
|
+
urlParsingNode.setAttribute('href', href);
|
1805
2020
|
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
2021
|
+
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
2022
|
+
return {
|
2023
|
+
href: urlParsingNode.href,
|
2024
|
+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
2025
|
+
host: urlParsingNode.host,
|
2026
|
+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
2027
|
+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
2028
|
+
hostname: urlParsingNode.hostname,
|
2029
|
+
port: urlParsingNode.port,
|
2030
|
+
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
2031
|
+
urlParsingNode.pathname :
|
2032
|
+
'/' + urlParsingNode.pathname
|
2033
|
+
};
|
1810
2034
|
}
|
1811
2035
|
|
1812
|
-
|
1813
|
-
|
1814
|
-
return this;
|
1815
|
-
}
|
1816
|
-
}
|
2036
|
+
originURL = resolveURL(window.location.href);
|
1817
2037
|
|
1818
|
-
|
2038
|
+
/**
|
2039
|
+
* Determine if a URL shares the same origin as the current location
|
2040
|
+
*
|
2041
|
+
* @param {String} requestURL The URL to test
|
2042
|
+
* @returns {boolean} True if URL shares the same origin, otherwise false
|
2043
|
+
*/
|
2044
|
+
return function isURLSameOrigin(requestURL) {
|
2045
|
+
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
2046
|
+
return (parsed.protocol === originURL.protocol &&
|
2047
|
+
parsed.host === originURL.host);
|
2048
|
+
};
|
2049
|
+
})() :
|
1819
2050
|
|
1820
|
-
|
1821
|
-
|
2051
|
+
// Non standard browser envs (web workers, react-native) lack needed support.
|
2052
|
+
(function nonStandardBrowserEnv() {
|
2053
|
+
return function isURLSameOrigin() {
|
2054
|
+
return true;
|
2055
|
+
};
|
2056
|
+
})();
|
1822
2057
|
|
1823
|
-
|
2058
|
+
function parseProtocol(url) {
|
2059
|
+
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
2060
|
+
return match && match[1] || '';
|
2061
|
+
}
|
1824
2062
|
|
1825
2063
|
/**
|
1826
2064
|
* Calculate data maxRate
|
@@ -1870,7 +2108,7 @@ function speedometer(samplesCount, min) {
|
|
1870
2108
|
|
1871
2109
|
const passed = startedAt && now - startedAt;
|
1872
2110
|
|
1873
|
-
return
|
2111
|
+
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
1874
2112
|
};
|
1875
2113
|
}
|
1876
2114
|
|
@@ -1903,7 +2141,9 @@ function progressEventReducer(listener, isDownloadStream) {
|
|
1903
2141
|
};
|
1904
2142
|
}
|
1905
2143
|
|
1906
|
-
|
2144
|
+
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
2145
|
+
|
2146
|
+
const xhrAdapter = isXHRAdapterSupported && function (config) {
|
1907
2147
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
1908
2148
|
let requestData = config.data;
|
1909
2149
|
const requestHeaders = AxiosHeaders$2.from(config.headers).normalize();
|
@@ -1919,7 +2159,7 @@ function xhrAdapter(config) {
|
|
1919
2159
|
}
|
1920
2160
|
}
|
1921
2161
|
|
1922
|
-
if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
|
2162
|
+
if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
|
1923
2163
|
requestHeaders.setContentType(false); // Let the browser set it
|
1924
2164
|
}
|
1925
2165
|
|
@@ -1947,7 +2187,7 @@ function xhrAdapter(config) {
|
|
1947
2187
|
const responseHeaders = AxiosHeaders$2.from(
|
1948
2188
|
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
1949
2189
|
);
|
1950
|
-
const responseData = !responseType || responseType === 'text' ||
|
2190
|
+
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
1951
2191
|
request.responseText : request.response;
|
1952
2192
|
const response = {
|
1953
2193
|
data: responseData,
|
@@ -2104,240 +2344,63 @@ function xhrAdapter(config) {
|
|
2104
2344
|
// Send the request
|
2105
2345
|
request.send(requestData || null);
|
2106
2346
|
});
|
2107
|
-
}
|
2108
|
-
|
2109
|
-
const adapters = {
|
2110
|
-
http: xhrAdapter,
|
2111
|
-
xhr: xhrAdapter
|
2112
|
-
};
|
2113
|
-
|
2114
|
-
const adapters$1 = {
|
2115
|
-
getAdapter: (nameOrAdapter) => {
|
2116
|
-
if(utils.isString(nameOrAdapter)){
|
2117
|
-
const adapter = adapters[nameOrAdapter];
|
2118
|
-
|
2119
|
-
if (!nameOrAdapter) {
|
2120
|
-
throw Error(
|
2121
|
-
utils.hasOwnProp(nameOrAdapter) ?
|
2122
|
-
`Adapter '${nameOrAdapter}' is not available in the build` :
|
2123
|
-
`Can not resolve adapter '${nameOrAdapter}'`
|
2124
|
-
);
|
2125
|
-
}
|
2126
|
-
|
2127
|
-
return adapter
|
2128
|
-
}
|
2129
|
-
|
2130
|
-
if (!utils.isFunction(nameOrAdapter)) {
|
2131
|
-
throw new TypeError('adapter is not a function');
|
2132
|
-
}
|
2133
|
-
|
2134
|
-
return nameOrAdapter;
|
2135
|
-
},
|
2136
|
-
adapters
|
2137
2347
|
};
|
2138
2348
|
|
2139
|
-
const
|
2140
|
-
|
2349
|
+
const knownAdapters = {
|
2350
|
+
http: httpAdapter,
|
2351
|
+
xhr: xhrAdapter
|
2141
2352
|
};
|
2142
2353
|
|
2143
|
-
|
2144
|
-
|
2145
|
-
* adapter
|
2146
|
-
*
|
2147
|
-
* @returns {Function}
|
2148
|
-
*/
|
2149
|
-
function getDefaultAdapter() {
|
2150
|
-
let adapter;
|
2151
|
-
if (typeof XMLHttpRequest !== 'undefined') {
|
2152
|
-
// For browsers use XHR adapter
|
2153
|
-
adapter = adapters$1.getAdapter('xhr');
|
2154
|
-
} else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
|
2155
|
-
// For node use HTTP adapter
|
2156
|
-
adapter = adapters$1.getAdapter('http');
|
2157
|
-
}
|
2158
|
-
return adapter;
|
2159
|
-
}
|
2160
|
-
|
2161
|
-
/**
|
2162
|
-
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
2163
|
-
* of the input
|
2164
|
-
*
|
2165
|
-
* @param {any} rawValue - The value to be stringified.
|
2166
|
-
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
2167
|
-
* @param {Function} encoder - A function that takes a value and returns a string.
|
2168
|
-
*
|
2169
|
-
* @returns {string} A stringified version of the rawValue.
|
2170
|
-
*/
|
2171
|
-
function stringifySafely(rawValue, parser, encoder) {
|
2172
|
-
if (utils.isString(rawValue)) {
|
2354
|
+
utils.forEach(knownAdapters, (fn, value) => {
|
2355
|
+
if(fn) {
|
2173
2356
|
try {
|
2174
|
-
(
|
2175
|
-
return utils.trim(rawValue);
|
2357
|
+
Object.defineProperty(fn, 'name', {value});
|
2176
2358
|
} catch (e) {
|
2177
|
-
|
2178
|
-
throw e;
|
2179
|
-
}
|
2359
|
+
// eslint-disable-next-line no-empty
|
2180
2360
|
}
|
2361
|
+
Object.defineProperty(fn, 'adapterName', {value});
|
2181
2362
|
}
|
2363
|
+
});
|
2182
2364
|
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
const defaults = {
|
2187
|
-
|
2188
|
-
transitional: transitionalDefaults,
|
2189
|
-
|
2190
|
-
adapter: getDefaultAdapter(),
|
2191
|
-
|
2192
|
-
transformRequest: [function transformRequest(data, headers) {
|
2193
|
-
const contentType = headers.getContentType() || '';
|
2194
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
2195
|
-
const isObjectPayload = utils.isObject(data);
|
2196
|
-
|
2197
|
-
if (isObjectPayload && utils.isHTMLForm(data)) {
|
2198
|
-
data = new FormData(data);
|
2199
|
-
}
|
2365
|
+
const adapters = {
|
2366
|
+
getAdapter: (adapters) => {
|
2367
|
+
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
2200
2368
|
|
2201
|
-
const
|
2369
|
+
const {length} = adapters;
|
2370
|
+
let nameOrAdapter;
|
2371
|
+
let adapter;
|
2202
2372
|
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2373
|
+
for (let i = 0; i < length; i++) {
|
2374
|
+
nameOrAdapter = adapters[i];
|
2375
|
+
if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
|
2376
|
+
break;
|
2206
2377
|
}
|
2207
|
-
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
2208
|
-
}
|
2209
|
-
|
2210
|
-
if (utils.isArrayBuffer(data) ||
|
2211
|
-
utils.isBuffer(data) ||
|
2212
|
-
utils.isStream(data) ||
|
2213
|
-
utils.isFile(data) ||
|
2214
|
-
utils.isBlob(data)
|
2215
|
-
) {
|
2216
|
-
return data;
|
2217
|
-
}
|
2218
|
-
if (utils.isArrayBufferView(data)) {
|
2219
|
-
return data.buffer;
|
2220
2378
|
}
|
2221
|
-
if (utils.isURLSearchParams(data)) {
|
2222
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
2223
|
-
return data.toString();
|
2224
|
-
}
|
2225
|
-
|
2226
|
-
let isFileList;
|
2227
|
-
|
2228
|
-
if (isObjectPayload) {
|
2229
|
-
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
2230
|
-
return toURLEncodedForm(data, this.formSerializer).toString();
|
2231
|
-
}
|
2232
|
-
|
2233
|
-
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
2234
|
-
const _FormData = this.env && this.env.FormData;
|
2235
2379
|
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2380
|
+
if (!adapter) {
|
2381
|
+
if (adapter === false) {
|
2382
|
+
throw new AxiosError$1(
|
2383
|
+
`Adapter ${nameOrAdapter} is not supported by the environment`,
|
2384
|
+
'ERR_NOT_SUPPORT'
|
2240
2385
|
);
|
2241
2386
|
}
|
2242
|
-
}
|
2243
2387
|
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2388
|
+
throw new Error(
|
2389
|
+
utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
|
2390
|
+
`Adapter '${nameOrAdapter}' is not available in the build` :
|
2391
|
+
`Unknown adapter '${nameOrAdapter}'`
|
2392
|
+
);
|
2247
2393
|
}
|
2248
2394
|
|
2249
|
-
|
2250
|
-
|
2251
|
-
|
2252
|
-
transformResponse: [function transformResponse(data) {
|
2253
|
-
const transitional = this.transitional || defaults.transitional;
|
2254
|
-
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
2255
|
-
const JSONRequested = this.responseType === 'json';
|
2256
|
-
|
2257
|
-
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
2258
|
-
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
2259
|
-
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
2260
|
-
|
2261
|
-
try {
|
2262
|
-
return JSON.parse(data);
|
2263
|
-
} catch (e) {
|
2264
|
-
if (strictJSONParsing) {
|
2265
|
-
if (e.name === 'SyntaxError') {
|
2266
|
-
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
2267
|
-
}
|
2268
|
-
throw e;
|
2269
|
-
}
|
2270
|
-
}
|
2395
|
+
if (!utils.isFunction(adapter)) {
|
2396
|
+
throw new TypeError('adapter is not a function');
|
2271
2397
|
}
|
2272
2398
|
|
2273
|
-
return
|
2274
|
-
}],
|
2275
|
-
|
2276
|
-
/**
|
2277
|
-
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
2278
|
-
* timeout is not created.
|
2279
|
-
*/
|
2280
|
-
timeout: 0,
|
2281
|
-
|
2282
|
-
xsrfCookieName: 'XSRF-TOKEN',
|
2283
|
-
xsrfHeaderName: 'X-XSRF-TOKEN',
|
2284
|
-
|
2285
|
-
maxContentLength: -1,
|
2286
|
-
maxBodyLength: -1,
|
2287
|
-
|
2288
|
-
env: {
|
2289
|
-
FormData: platform.classes.FormData,
|
2290
|
-
Blob: platform.classes.Blob
|
2291
|
-
},
|
2292
|
-
|
2293
|
-
validateStatus: function validateStatus(status) {
|
2294
|
-
return status >= 200 && status < 300;
|
2399
|
+
return adapter;
|
2295
2400
|
},
|
2296
|
-
|
2297
|
-
headers: {
|
2298
|
-
common: {
|
2299
|
-
'Accept': 'application/json, text/plain, */*'
|
2300
|
-
}
|
2301
|
-
}
|
2401
|
+
adapters: knownAdapters
|
2302
2402
|
};
|
2303
2403
|
|
2304
|
-
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
2305
|
-
defaults.headers[method] = {};
|
2306
|
-
});
|
2307
|
-
|
2308
|
-
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
2309
|
-
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
2310
|
-
});
|
2311
|
-
|
2312
|
-
const defaults$1 = defaults;
|
2313
|
-
|
2314
|
-
/**
|
2315
|
-
* Transform the data for a request or a response
|
2316
|
-
*
|
2317
|
-
* @param {Array|Function} fns A single function or Array of functions
|
2318
|
-
* @param {?Object} response The response object
|
2319
|
-
*
|
2320
|
-
* @returns {*} The resulting transformed data
|
2321
|
-
*/
|
2322
|
-
function transformData(fns, response) {
|
2323
|
-
const config = this || defaults$1;
|
2324
|
-
const context = response || config;
|
2325
|
-
const headers = AxiosHeaders$2.from(context.headers);
|
2326
|
-
let data = context.data;
|
2327
|
-
|
2328
|
-
utils.forEach(fns, function transform(fn) {
|
2329
|
-
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
2330
|
-
});
|
2331
|
-
|
2332
|
-
headers.normalize();
|
2333
|
-
|
2334
|
-
return data;
|
2335
|
-
}
|
2336
|
-
|
2337
|
-
function isCancel$1(value) {
|
2338
|
-
return !!(value && value.__CANCEL__);
|
2339
|
-
}
|
2340
|
-
|
2341
2404
|
/**
|
2342
2405
|
* Throws a `CanceledError` if cancellation has been requested.
|
2343
2406
|
*
|
@@ -2351,7 +2414,7 @@ function throwIfCancellationRequested(config) {
|
|
2351
2414
|
}
|
2352
2415
|
|
2353
2416
|
if (config.signal && config.signal.aborted) {
|
2354
|
-
throw new CanceledError$1();
|
2417
|
+
throw new CanceledError$1(null, config);
|
2355
2418
|
}
|
2356
2419
|
}
|
2357
2420
|
|
@@ -2377,7 +2440,7 @@ function dispatchRequest(config) {
|
|
2377
2440
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
2378
2441
|
}
|
2379
2442
|
|
2380
|
-
const adapter = config.adapter || defaults$1.adapter;
|
2443
|
+
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
2381
2444
|
|
2382
2445
|
return adapter(config).then(function onAdapterResolution(response) {
|
2383
2446
|
throwIfCancellationRequested(config);
|
@@ -2422,7 +2485,7 @@ const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? thing.toJSO
|
|
2422
2485
|
*
|
2423
2486
|
* @returns {Object} New object resulting from merging config2 to config1
|
2424
2487
|
*/
|
2425
|
-
function mergeConfig(config1, config2) {
|
2488
|
+
function mergeConfig$1(config1, config2) {
|
2426
2489
|
// eslint-disable-next-line no-param-reassign
|
2427
2490
|
config2 = config2 || {};
|
2428
2491
|
const config = {};
|
@@ -2512,7 +2575,7 @@ function mergeConfig(config1, config2) {
|
|
2512
2575
|
return config;
|
2513
2576
|
}
|
2514
2577
|
|
2515
|
-
const VERSION$1 = "1.2.
|
2578
|
+
const VERSION$1 = "1.2.1";
|
2516
2579
|
|
2517
2580
|
const validators$1 = {};
|
2518
2581
|
|
@@ -2637,7 +2700,7 @@ class Axios$1 {
|
|
2637
2700
|
config = configOrUrl || {};
|
2638
2701
|
}
|
2639
2702
|
|
2640
|
-
config = mergeConfig(this.defaults, config);
|
2703
|
+
config = mergeConfig$1(this.defaults, config);
|
2641
2704
|
|
2642
2705
|
const {transitional, paramsSerializer, headers} = config;
|
2643
2706
|
|
@@ -2747,7 +2810,7 @@ class Axios$1 {
|
|
2747
2810
|
}
|
2748
2811
|
|
2749
2812
|
getUri(config) {
|
2750
|
-
config = mergeConfig(this.defaults, config);
|
2813
|
+
config = mergeConfig$1(this.defaults, config);
|
2751
2814
|
const fullPath = buildFullPath(config.baseURL, config.url);
|
2752
2815
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
2753
2816
|
}
|
@@ -2757,7 +2820,7 @@ class Axios$1 {
|
|
2757
2820
|
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
2758
2821
|
/*eslint func-names:0*/
|
2759
2822
|
Axios$1.prototype[method] = function(url, config) {
|
2760
|
-
return this.request(mergeConfig(config || {}, {
|
2823
|
+
return this.request(mergeConfig$1(config || {}, {
|
2761
2824
|
method,
|
2762
2825
|
url,
|
2763
2826
|
data: (config || {}).data
|
@@ -2770,7 +2833,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2770
2833
|
|
2771
2834
|
function generateHTTPMethod(isForm) {
|
2772
2835
|
return function httpMethod(url, data, config) {
|
2773
|
-
return this.request(mergeConfig(config || {}, {
|
2836
|
+
return this.request(mergeConfig$1(config || {}, {
|
2774
2837
|
method,
|
2775
2838
|
headers: isForm ? {
|
2776
2839
|
'Content-Type': 'multipart/form-data'
|
@@ -2963,7 +3026,7 @@ function createInstance(defaultConfig) {
|
|
2963
3026
|
|
2964
3027
|
// Factory for creating new instances
|
2965
3028
|
instance.create = function create(instanceConfig) {
|
2966
|
-
return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
3029
|
+
return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
|
2967
3030
|
};
|
2968
3031
|
|
2969
3032
|
return instance;
|
@@ -2998,6 +3061,9 @@ axios.spread = spread$1;
|
|
2998
3061
|
// Expose isAxiosError
|
2999
3062
|
axios.isAxiosError = isAxiosError$1;
|
3000
3063
|
|
3064
|
+
// Expose mergeConfig
|
3065
|
+
axios.mergeConfig = mergeConfig$1;
|
3066
|
+
|
3001
3067
|
axios.AxiosHeaders = AxiosHeaders$2;
|
3002
3068
|
|
3003
3069
|
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
@@ -3023,8 +3089,9 @@ const {
|
|
3023
3089
|
spread,
|
3024
3090
|
toFormData,
|
3025
3091
|
AxiosHeaders,
|
3026
|
-
formToJSON
|
3092
|
+
formToJSON,
|
3093
|
+
mergeConfig
|
3027
3094
|
} = axios$1;
|
3028
3095
|
|
3029
|
-
export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, spread, toFormData };
|
3096
|
+
export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, mergeConfig, spread, toFormData };
|
3030
3097
|
//# sourceMappingURL=axios.js.map
|