axios 1.1.2 → 1.2.0-alpha.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 +123 -39
- package/{UPGRADE_GUIDE.md → MIGRATION_GUIDE.md} +1 -1
- package/README.md +155 -36
- package/dist/axios.js +563 -681
- 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 +3010 -0
- package/dist/browser/axios.cjs.map +1 -0
- package/dist/esm/axios.js +323 -235
- 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 +256 -189
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +490 -0
- package/index.d.ts +35 -12
- package/index.js +36 -1
- package/karma.conf.cjs +1 -1
- package/lib/adapters/http.js +8 -5
- package/lib/adapters/xhr.js +2 -1
- package/lib/axios.js +7 -3
- package/lib/core/Axios.js +17 -8
- package/lib/core/AxiosHeaders.js +83 -83
- package/lib/core/dispatchRequest.js +4 -0
- package/lib/core/mergeConfig.js +50 -46
- package/lib/defaults/index.js +1 -1
- package/lib/env/data.js +1 -1
- package/lib/helpers/buildURL.js +17 -10
- package/lib/helpers/toFormData.js +2 -2
- package/lib/utils.js +36 -8
- package/package.json +14 -6
- package/rollup.config.js +37 -10
- package/tsconfig.json +2 -7
- package/tslint.json +6 -1
package/dist/esm/axios.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.1
|
1
|
+
// Axios v1.2.0-alpha.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);
|
@@ -231,7 +231,7 @@ const trim = (str) => str.trim ?
|
|
231
231
|
* @param {Function} fn The callback to invoke for each item
|
232
232
|
*
|
233
233
|
* @param {Boolean} [allOwnKeys = false]
|
234
|
-
* @returns {
|
234
|
+
* @returns {any}
|
235
235
|
*/
|
236
236
|
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
237
237
|
// Don't bother if no value provided
|
@@ -266,6 +266,24 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
266
266
|
}
|
267
267
|
}
|
268
268
|
|
269
|
+
function findKey(obj, key) {
|
270
|
+
key = key.toLowerCase();
|
271
|
+
const keys = Object.keys(obj);
|
272
|
+
let i = keys.length;
|
273
|
+
let _key;
|
274
|
+
while (i-- > 0) {
|
275
|
+
_key = keys[i];
|
276
|
+
if (key === _key.toLowerCase()) {
|
277
|
+
return _key;
|
278
|
+
}
|
279
|
+
}
|
280
|
+
return null;
|
281
|
+
}
|
282
|
+
|
283
|
+
const _global = typeof self === "undefined" ? typeof global === "undefined" ? undefined : global : self;
|
284
|
+
|
285
|
+
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
286
|
+
|
269
287
|
/**
|
270
288
|
* Accepts varargs expecting each argument to be an object, then
|
271
289
|
* immutably merges the properties of each object and returns result.
|
@@ -285,16 +303,18 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
285
303
|
* @returns {Object} Result of all merge properties
|
286
304
|
*/
|
287
305
|
function merge(/* obj1, obj2, obj3, ... */) {
|
306
|
+
const {caseless} = isContextDefined(this) && this || {};
|
288
307
|
const result = {};
|
289
308
|
const assignValue = (val, key) => {
|
290
|
-
|
291
|
-
|
309
|
+
const targetKey = caseless && findKey(result, key) || key;
|
310
|
+
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
311
|
+
result[targetKey] = merge(result[targetKey], val);
|
292
312
|
} else if (isPlainObject(val)) {
|
293
|
-
result[
|
313
|
+
result[targetKey] = merge({}, val);
|
294
314
|
} else if (isArray(val)) {
|
295
|
-
result[
|
315
|
+
result[targetKey] = val.slice();
|
296
316
|
} else {
|
297
|
-
result[
|
317
|
+
result[targetKey] = val;
|
298
318
|
}
|
299
319
|
};
|
300
320
|
|
@@ -530,6 +550,11 @@ const reduceDescriptors = (obj, reducer) => {
|
|
530
550
|
|
531
551
|
const freezeMethods = (obj) => {
|
532
552
|
reduceDescriptors(obj, (descriptor, name) => {
|
553
|
+
// skip restricted props in strict mode
|
554
|
+
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
555
|
+
return false;
|
556
|
+
}
|
557
|
+
|
533
558
|
const value = obj[name];
|
534
559
|
|
535
560
|
if (!isFunction(value)) return;
|
@@ -543,7 +568,7 @@ const freezeMethods = (obj) => {
|
|
543
568
|
|
544
569
|
if (!descriptor.set) {
|
545
570
|
descriptor.set = () => {
|
546
|
-
throw Error('Can not read-only method \'' + name + '\'');
|
571
|
+
throw Error('Can not rewrite read-only method \'' + name + '\'');
|
547
572
|
};
|
548
573
|
}
|
549
574
|
});
|
@@ -612,7 +637,10 @@ const utils = {
|
|
612
637
|
toObjectSet,
|
613
638
|
toCamelCase,
|
614
639
|
noop,
|
615
|
-
toFiniteNumber
|
640
|
+
toFiniteNumber,
|
641
|
+
findKey,
|
642
|
+
global: _global,
|
643
|
+
isContextDefined
|
616
644
|
};
|
617
645
|
|
618
646
|
/**
|
@@ -626,7 +654,7 @@ const utils = {
|
|
626
654
|
*
|
627
655
|
* @returns {Error} The created error.
|
628
656
|
*/
|
629
|
-
function AxiosError(message, code, config, request, response) {
|
657
|
+
function AxiosError$1(message, code, config, request, response) {
|
630
658
|
Error.call(this);
|
631
659
|
|
632
660
|
if (Error.captureStackTrace) {
|
@@ -643,7 +671,7 @@ function AxiosError(message, code, config, request, response) {
|
|
643
671
|
response && (this.response = response);
|
644
672
|
}
|
645
673
|
|
646
|
-
utils.inherits(AxiosError, Error, {
|
674
|
+
utils.inherits(AxiosError$1, Error, {
|
647
675
|
toJSON: function toJSON() {
|
648
676
|
return {
|
649
677
|
// Standard
|
@@ -665,7 +693,7 @@ utils.inherits(AxiosError, Error, {
|
|
665
693
|
}
|
666
694
|
});
|
667
695
|
|
668
|
-
const prototype$1 = AxiosError.prototype;
|
696
|
+
const prototype$1 = AxiosError$1.prototype;
|
669
697
|
const descriptors = {};
|
670
698
|
|
671
699
|
[
|
@@ -686,11 +714,11 @@ const descriptors = {};
|
|
686
714
|
descriptors[code] = {value: code};
|
687
715
|
});
|
688
716
|
|
689
|
-
Object.defineProperties(AxiosError, descriptors);
|
717
|
+
Object.defineProperties(AxiosError$1, descriptors);
|
690
718
|
Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
691
719
|
|
692
720
|
// eslint-disable-next-line func-names
|
693
|
-
AxiosError.from = (error, code, config, request, response, customProps) => {
|
721
|
+
AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
694
722
|
const axiosError = Object.create(prototype$1);
|
695
723
|
|
696
724
|
utils.toFlatObject(error, axiosError, function filter(obj) {
|
@@ -699,7 +727,7 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
699
727
|
return prop !== 'isAxiosError';
|
700
728
|
});
|
701
729
|
|
702
|
-
AxiosError.call(axiosError, error.message, code, config, request, response);
|
730
|
+
AxiosError$1.call(axiosError, error.message, code, config, request, response);
|
703
731
|
|
704
732
|
axiosError.cause = error;
|
705
733
|
|
@@ -713,6 +741,8 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
713
741
|
/* eslint-env browser */
|
714
742
|
var browser = typeof self == 'object' ? self.FormData : window.FormData;
|
715
743
|
|
744
|
+
const FormData$2 = browser;
|
745
|
+
|
716
746
|
/**
|
717
747
|
* Determines if the given thing is a array or js object.
|
718
748
|
*
|
@@ -802,13 +832,13 @@ function isSpecCompliant(thing) {
|
|
802
832
|
*
|
803
833
|
* @returns
|
804
834
|
*/
|
805
|
-
function toFormData(obj, formData, options) {
|
835
|
+
function toFormData$1(obj, formData, options) {
|
806
836
|
if (!utils.isObject(obj)) {
|
807
837
|
throw new TypeError('target must be an object');
|
808
838
|
}
|
809
839
|
|
810
840
|
// eslint-disable-next-line no-param-reassign
|
811
|
-
formData = formData || new (
|
841
|
+
formData = formData || new (FormData$2 || FormData)();
|
812
842
|
|
813
843
|
// eslint-disable-next-line no-param-reassign
|
814
844
|
options = utils.toFlatObject(options, {
|
@@ -840,7 +870,7 @@ function toFormData(obj, formData, options) {
|
|
840
870
|
}
|
841
871
|
|
842
872
|
if (!useBlob && utils.isBlob(value)) {
|
843
|
-
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
873
|
+
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
844
874
|
}
|
845
875
|
|
846
876
|
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
|
@@ -877,7 +907,7 @@ function toFormData(obj, formData, options) {
|
|
877
907
|
key = removeBrackets(key);
|
878
908
|
|
879
909
|
arr.forEach(function each(el, index) {
|
880
|
-
!utils.isUndefined(el) && formData.append(
|
910
|
+
!(utils.isUndefined(el) || el === null) && formData.append(
|
881
911
|
// eslint-disable-next-line no-nested-ternary
|
882
912
|
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
883
913
|
convertValue(el)
|
@@ -914,7 +944,7 @@ function toFormData(obj, formData, options) {
|
|
914
944
|
stack.push(value);
|
915
945
|
|
916
946
|
utils.forEach(value, function each(el, key) {
|
917
|
-
const result = !utils.isUndefined(el) && visitor.call(
|
947
|
+
const result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
918
948
|
formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
|
919
949
|
);
|
920
950
|
|
@@ -969,7 +999,7 @@ function encode$1(str) {
|
|
969
999
|
function AxiosURLSearchParams(params, options) {
|
970
1000
|
this._pairs = [];
|
971
1001
|
|
972
|
-
params && toFormData(params, this, options);
|
1002
|
+
params && toFormData$1(params, this, options);
|
973
1003
|
}
|
974
1004
|
|
975
1005
|
const prototype = AxiosURLSearchParams.prototype;
|
@@ -1020,21 +1050,28 @@ function buildURL(url, params, options) {
|
|
1020
1050
|
if (!params) {
|
1021
1051
|
return url;
|
1022
1052
|
}
|
1053
|
+
|
1054
|
+
const _encode = options && options.encode || encode;
|
1023
1055
|
|
1024
|
-
const
|
1056
|
+
const serializeFn = options && options.serialize;
|
1025
1057
|
|
1026
|
-
|
1027
|
-
url = url.slice(0, hashmarkIndex);
|
1028
|
-
}
|
1058
|
+
let serializedParams;
|
1029
1059
|
|
1030
|
-
|
1060
|
+
if (serializeFn) {
|
1061
|
+
serializedParams = serializeFn(params, options);
|
1062
|
+
} else {
|
1063
|
+
serializedParams = utils.isURLSearchParams(params) ?
|
1064
|
+
params.toString() :
|
1065
|
+
new AxiosURLSearchParams(params, options).toString(_encode);
|
1066
|
+
}
|
1031
1067
|
|
1032
|
-
|
1033
|
-
|
1034
|
-
new AxiosURLSearchParams(params, options).toString(_encode);
|
1068
|
+
if (serializedParams) {
|
1069
|
+
const hashmarkIndex = url.indexOf("#");
|
1035
1070
|
|
1036
|
-
|
1037
|
-
|
1071
|
+
if (hashmarkIndex !== -1) {
|
1072
|
+
url = url.slice(0, hashmarkIndex);
|
1073
|
+
}
|
1074
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
1038
1075
|
}
|
1039
1076
|
|
1040
1077
|
return url;
|
@@ -1106,6 +1143,8 @@ class InterceptorManager {
|
|
1106
1143
|
}
|
1107
1144
|
}
|
1108
1145
|
|
1146
|
+
const InterceptorManager$1 = InterceptorManager;
|
1147
|
+
|
1109
1148
|
const transitionalDefaults = {
|
1110
1149
|
silentJSONParsing: true,
|
1111
1150
|
forcedJSONParsing: true,
|
@@ -1158,7 +1197,7 @@ const platform = {
|
|
1158
1197
|
};
|
1159
1198
|
|
1160
1199
|
function toURLEncodedForm(data, options) {
|
1161
|
-
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
1200
|
+
return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
|
1162
1201
|
visitor: function(value, key, path, helpers) {
|
1163
1202
|
if (platform.isNode && utils.isBuffer(value)) {
|
1164
1203
|
this.append(key, value.toString('base64'));
|
@@ -1271,9 +1310,9 @@ function settle(resolve, reject, response) {
|
|
1271
1310
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
1272
1311
|
resolve(response);
|
1273
1312
|
} else {
|
1274
|
-
reject(new AxiosError(
|
1313
|
+
reject(new AxiosError$1(
|
1275
1314
|
'Request failed with status code ' + response.status,
|
1276
|
-
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
1315
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
1277
1316
|
response.config,
|
1278
1317
|
response.request,
|
1279
1318
|
response
|
@@ -1446,13 +1485,13 @@ const isURLSameOrigin = platform.isStandardBrowserEnv ?
|
|
1446
1485
|
*
|
1447
1486
|
* @returns {CanceledError} The created error.
|
1448
1487
|
*/
|
1449
|
-
function CanceledError(message, config, request) {
|
1488
|
+
function CanceledError$1(message, config, request) {
|
1450
1489
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
1451
|
-
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
1490
|
+
AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
1452
1491
|
this.name = 'CanceledError';
|
1453
1492
|
}
|
1454
1493
|
|
1455
|
-
utils.inherits(CanceledError, AxiosError, {
|
1494
|
+
utils.inherits(CanceledError$1, AxiosError$1, {
|
1456
1495
|
__CANCEL__: true
|
1457
1496
|
});
|
1458
1497
|
|
@@ -1514,7 +1553,6 @@ const parseHeaders = rawHeaders => {
|
|
1514
1553
|
};
|
1515
1554
|
|
1516
1555
|
const $internals = Symbol('internals');
|
1517
|
-
const $defaults = Symbol('defaults');
|
1518
1556
|
|
1519
1557
|
function normalizeHeader(header) {
|
1520
1558
|
return header && String(header).trim().toLowerCase();
|
@@ -1525,7 +1563,7 @@ function normalizeValue(value) {
|
|
1525
1563
|
return value;
|
1526
1564
|
}
|
1527
1565
|
|
1528
|
-
return String(value);
|
1566
|
+
return utils.isArray(value) ? value.map(normalizeValue) : String(value);
|
1529
1567
|
}
|
1530
1568
|
|
1531
1569
|
function parseTokens(str) {
|
@@ -1540,6 +1578,10 @@ function parseTokens(str) {
|
|
1540
1578
|
return tokens;
|
1541
1579
|
}
|
1542
1580
|
|
1581
|
+
function isValidHeaderName(str) {
|
1582
|
+
return /^[-_a-zA-Z]+$/.test(str.trim());
|
1583
|
+
}
|
1584
|
+
|
1543
1585
|
function matchHeaderValue(context, value, header, filter) {
|
1544
1586
|
if (utils.isFunction(filter)) {
|
1545
1587
|
return filter.call(this, value, header);
|
@@ -1576,27 +1618,12 @@ function buildAccessors(obj, header) {
|
|
1576
1618
|
});
|
1577
1619
|
}
|
1578
1620
|
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
let i = keys.length;
|
1583
|
-
let _key;
|
1584
|
-
while (i-- > 0) {
|
1585
|
-
_key = keys[i];
|
1586
|
-
if (key === _key.toLowerCase()) {
|
1587
|
-
return _key;
|
1588
|
-
}
|
1621
|
+
class AxiosHeaders$1 {
|
1622
|
+
constructor(headers) {
|
1623
|
+
headers && this.set(headers);
|
1589
1624
|
}
|
1590
|
-
return null;
|
1591
|
-
}
|
1592
1625
|
|
1593
|
-
|
1594
|
-
headers && this.set(headers);
|
1595
|
-
this[$defaults] = defaults || null;
|
1596
|
-
}
|
1597
|
-
|
1598
|
-
Object.assign(AxiosHeaders.prototype, {
|
1599
|
-
set: function(header, valueOrRewrite, rewrite) {
|
1626
|
+
set(header, valueOrRewrite, rewrite) {
|
1600
1627
|
const self = this;
|
1601
1628
|
|
1602
1629
|
function setHeader(_value, _header, _rewrite) {
|
@@ -1606,75 +1633,70 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1606
1633
|
throw new Error('header name must be a non-empty string');
|
1607
1634
|
}
|
1608
1635
|
|
1609
|
-
const key = findKey(self, lHeader);
|
1636
|
+
const key = utils.findKey(self, lHeader);
|
1610
1637
|
|
1611
|
-
if
|
1612
|
-
|
1638
|
+
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
1639
|
+
self[key || _header] = normalizeValue(_value);
|
1613
1640
|
}
|
1614
|
-
|
1615
|
-
if (utils.isArray(_value)) {
|
1616
|
-
_value = _value.map(normalizeValue);
|
1617
|
-
} else {
|
1618
|
-
_value = normalizeValue(_value);
|
1619
|
-
}
|
1620
|
-
|
1621
|
-
self[key || _header] = _value;
|
1622
1641
|
}
|
1623
1642
|
|
1624
|
-
|
1625
|
-
utils.forEach(
|
1626
|
-
|
1627
|
-
|
1643
|
+
const setHeaders = (headers, _rewrite) =>
|
1644
|
+
utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
1645
|
+
|
1646
|
+
if (utils.isPlainObject(header) || header instanceof this.constructor) {
|
1647
|
+
setHeaders(header, valueOrRewrite);
|
1648
|
+
} else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
1649
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
1628
1650
|
} else {
|
1629
|
-
setHeader(valueOrRewrite, header, rewrite);
|
1651
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
1630
1652
|
}
|
1631
1653
|
|
1632
1654
|
return this;
|
1633
|
-
}
|
1655
|
+
}
|
1634
1656
|
|
1635
|
-
get
|
1657
|
+
get(header, parser) {
|
1636
1658
|
header = normalizeHeader(header);
|
1637
1659
|
|
1638
|
-
if (
|
1660
|
+
if (header) {
|
1661
|
+
const key = utils.findKey(this, header);
|
1639
1662
|
|
1640
|
-
|
1663
|
+
if (key) {
|
1664
|
+
const value = this[key];
|
1641
1665
|
|
1642
|
-
|
1643
|
-
|
1666
|
+
if (!parser) {
|
1667
|
+
return value;
|
1668
|
+
}
|
1644
1669
|
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1670
|
+
if (parser === true) {
|
1671
|
+
return parseTokens(value);
|
1672
|
+
}
|
1648
1673
|
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1674
|
+
if (utils.isFunction(parser)) {
|
1675
|
+
return parser.call(this, value, key);
|
1676
|
+
}
|
1652
1677
|
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1678
|
+
if (utils.isRegExp(parser)) {
|
1679
|
+
return parser.exec(value);
|
1680
|
+
}
|
1656
1681
|
|
1657
|
-
|
1658
|
-
return parser.exec(value);
|
1682
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
1659
1683
|
}
|
1660
|
-
|
1661
|
-
throw new TypeError('parser must be boolean|regexp|function');
|
1662
1684
|
}
|
1663
|
-
}
|
1685
|
+
}
|
1664
1686
|
|
1665
|
-
has
|
1687
|
+
has(header, matcher) {
|
1666
1688
|
header = normalizeHeader(header);
|
1667
1689
|
|
1668
1690
|
if (header) {
|
1669
|
-
const key = findKey(this, header);
|
1691
|
+
const key = utils.findKey(this, header);
|
1670
1692
|
|
1671
1693
|
return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1672
1694
|
}
|
1673
1695
|
|
1674
1696
|
return false;
|
1675
|
-
}
|
1697
|
+
}
|
1676
1698
|
|
1677
|
-
delete
|
1699
|
+
delete(header, matcher) {
|
1678
1700
|
const self = this;
|
1679
1701
|
let deleted = false;
|
1680
1702
|
|
@@ -1682,7 +1704,7 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1682
1704
|
_header = normalizeHeader(_header);
|
1683
1705
|
|
1684
1706
|
if (_header) {
|
1685
|
-
const key = findKey(self, _header);
|
1707
|
+
const key = utils.findKey(self, _header);
|
1686
1708
|
|
1687
1709
|
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
1688
1710
|
delete self[key];
|
@@ -1699,18 +1721,18 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1699
1721
|
}
|
1700
1722
|
|
1701
1723
|
return deleted;
|
1702
|
-
}
|
1724
|
+
}
|
1703
1725
|
|
1704
|
-
clear
|
1726
|
+
clear() {
|
1705
1727
|
return Object.keys(this).forEach(this.delete.bind(this));
|
1706
|
-
}
|
1728
|
+
}
|
1707
1729
|
|
1708
|
-
normalize
|
1730
|
+
normalize(format) {
|
1709
1731
|
const self = this;
|
1710
1732
|
const headers = {};
|
1711
1733
|
|
1712
1734
|
utils.forEach(this, (value, header) => {
|
1713
|
-
const key = findKey(headers, header);
|
1735
|
+
const key = utils.findKey(headers, header);
|
1714
1736
|
|
1715
1737
|
if (key) {
|
1716
1738
|
self[key] = normalizeValue(value);
|
@@ -1730,30 +1752,47 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1730
1752
|
});
|
1731
1753
|
|
1732
1754
|
return this;
|
1733
|
-
}
|
1755
|
+
}
|
1756
|
+
|
1757
|
+
concat(...targets) {
|
1758
|
+
return this.constructor.concat(this, ...targets);
|
1759
|
+
}
|
1734
1760
|
|
1735
|
-
toJSON
|
1761
|
+
toJSON(asStrings) {
|
1736
1762
|
const obj = Object.create(null);
|
1737
1763
|
|
1738
|
-
utils.forEach(
|
1739
|
-
(value,
|
1740
|
-
|
1741
|
-
obj[header] = utils.isArray(value) ? value.join(', ') : value;
|
1742
|
-
});
|
1764
|
+
utils.forEach(this, (value, header) => {
|
1765
|
+
value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
|
1766
|
+
});
|
1743
1767
|
|
1744
1768
|
return obj;
|
1745
1769
|
}
|
1746
|
-
});
|
1747
1770
|
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1771
|
+
[Symbol.iterator]() {
|
1772
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
1773
|
+
}
|
1774
|
+
|
1775
|
+
toString() {
|
1776
|
+
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
1777
|
+
}
|
1778
|
+
|
1779
|
+
get [Symbol.toStringTag]() {
|
1780
|
+
return 'AxiosHeaders';
|
1781
|
+
}
|
1782
|
+
|
1783
|
+
static from(thing) {
|
1753
1784
|
return thing instanceof this ? thing : new this(thing);
|
1754
|
-
}
|
1785
|
+
}
|
1755
1786
|
|
1756
|
-
|
1787
|
+
static concat(first, ...targets) {
|
1788
|
+
const computed = new this(first);
|
1789
|
+
|
1790
|
+
targets.forEach((target) => computed.set(target));
|
1791
|
+
|
1792
|
+
return computed;
|
1793
|
+
}
|
1794
|
+
|
1795
|
+
static accessor(header) {
|
1757
1796
|
const internals = this[$internals] = (this[$internals] = {
|
1758
1797
|
accessors: {}
|
1759
1798
|
});
|
@@ -1774,12 +1813,14 @@ Object.assign(AxiosHeaders, {
|
|
1774
1813
|
|
1775
1814
|
return this;
|
1776
1815
|
}
|
1777
|
-
}
|
1816
|
+
}
|
1778
1817
|
|
1779
|
-
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
|
1818
|
+
AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
|
1780
1819
|
|
1781
|
-
utils.freezeMethods(AxiosHeaders.prototype);
|
1782
|
-
utils.freezeMethods(AxiosHeaders);
|
1820
|
+
utils.freezeMethods(AxiosHeaders$1.prototype);
|
1821
|
+
utils.freezeMethods(AxiosHeaders$1);
|
1822
|
+
|
1823
|
+
const AxiosHeaders$2 = AxiosHeaders$1;
|
1783
1824
|
|
1784
1825
|
/**
|
1785
1826
|
* Calculate data maxRate
|
@@ -1852,7 +1893,8 @@ function progressEventReducer(listener, isDownloadStream) {
|
|
1852
1893
|
progress: total ? (loaded / total) : undefined,
|
1853
1894
|
bytes: progressBytes,
|
1854
1895
|
rate: rate ? rate : undefined,
|
1855
|
-
estimated: rate && total && inRange ? (total - loaded) / rate : undefined
|
1896
|
+
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
1897
|
+
event: e
|
1856
1898
|
};
|
1857
1899
|
|
1858
1900
|
data[isDownloadStream ? 'download' : 'upload'] = true;
|
@@ -1864,7 +1906,7 @@ function progressEventReducer(listener, isDownloadStream) {
|
|
1864
1906
|
function xhrAdapter(config) {
|
1865
1907
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
1866
1908
|
let requestData = config.data;
|
1867
|
-
const requestHeaders = AxiosHeaders.from(config.headers).normalize();
|
1909
|
+
const requestHeaders = AxiosHeaders$2.from(config.headers).normalize();
|
1868
1910
|
const responseType = config.responseType;
|
1869
1911
|
let onCanceled;
|
1870
1912
|
function done() {
|
@@ -1902,7 +1944,7 @@ function xhrAdapter(config) {
|
|
1902
1944
|
return;
|
1903
1945
|
}
|
1904
1946
|
// Prepare the response
|
1905
|
-
const responseHeaders = AxiosHeaders.from(
|
1947
|
+
const responseHeaders = AxiosHeaders$2.from(
|
1906
1948
|
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
1907
1949
|
);
|
1908
1950
|
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
@@ -1957,7 +1999,7 @@ function xhrAdapter(config) {
|
|
1957
1999
|
return;
|
1958
2000
|
}
|
1959
2001
|
|
1960
|
-
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
2002
|
+
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
1961
2003
|
|
1962
2004
|
// Clean up request
|
1963
2005
|
request = null;
|
@@ -1967,7 +2009,7 @@ function xhrAdapter(config) {
|
|
1967
2009
|
request.onerror = function handleError() {
|
1968
2010
|
// Real errors are hidden from us by the browser
|
1969
2011
|
// onerror should only fire if it's a network error
|
1970
|
-
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
|
2012
|
+
reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
|
1971
2013
|
|
1972
2014
|
// Clean up request
|
1973
2015
|
request = null;
|
@@ -1980,9 +2022,9 @@ function xhrAdapter(config) {
|
|
1980
2022
|
if (config.timeoutErrorMessage) {
|
1981
2023
|
timeoutErrorMessage = config.timeoutErrorMessage;
|
1982
2024
|
}
|
1983
|
-
reject(new AxiosError(
|
2025
|
+
reject(new AxiosError$1(
|
1984
2026
|
timeoutErrorMessage,
|
1985
|
-
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
2027
|
+
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
1986
2028
|
config,
|
1987
2029
|
request));
|
1988
2030
|
|
@@ -2040,7 +2082,7 @@ function xhrAdapter(config) {
|
|
2040
2082
|
if (!request) {
|
2041
2083
|
return;
|
2042
2084
|
}
|
2043
|
-
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
2085
|
+
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
2044
2086
|
request.abort();
|
2045
2087
|
request = null;
|
2046
2088
|
};
|
@@ -2054,7 +2096,7 @@ function xhrAdapter(config) {
|
|
2054
2096
|
const protocol = parseProtocol(fullPath);
|
2055
2097
|
|
2056
2098
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
2057
|
-
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
2099
|
+
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
2058
2100
|
return;
|
2059
2101
|
}
|
2060
2102
|
|
@@ -2095,7 +2137,7 @@ const adapters$1 = {
|
|
2095
2137
|
};
|
2096
2138
|
|
2097
2139
|
const DEFAULT_CONTENT_TYPE = {
|
2098
|
-
'Content-Type':
|
2140
|
+
'Content-Type': undefined
|
2099
2141
|
};
|
2100
2142
|
|
2101
2143
|
/**
|
@@ -2191,7 +2233,7 @@ const defaults = {
|
|
2191
2233
|
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
2192
2234
|
const _FormData = this.env && this.env.FormData;
|
2193
2235
|
|
2194
|
-
return toFormData(
|
2236
|
+
return toFormData$1(
|
2195
2237
|
isFileList ? {'files[]': data} : data,
|
2196
2238
|
_FormData && new _FormData(),
|
2197
2239
|
this.formSerializer
|
@@ -2221,7 +2263,7 @@ const defaults = {
|
|
2221
2263
|
} catch (e) {
|
2222
2264
|
if (strictJSONParsing) {
|
2223
2265
|
if (e.name === 'SyntaxError') {
|
2224
|
-
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
2266
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
2225
2267
|
}
|
2226
2268
|
throw e;
|
2227
2269
|
}
|
@@ -2267,6 +2309,8 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2267
2309
|
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
2268
2310
|
});
|
2269
2311
|
|
2312
|
+
const defaults$1 = defaults;
|
2313
|
+
|
2270
2314
|
/**
|
2271
2315
|
* Transform the data for a request or a response
|
2272
2316
|
*
|
@@ -2276,9 +2320,9 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2276
2320
|
* @returns {*} The resulting transformed data
|
2277
2321
|
*/
|
2278
2322
|
function transformData(fns, response) {
|
2279
|
-
const config = this || defaults;
|
2323
|
+
const config = this || defaults$1;
|
2280
2324
|
const context = response || config;
|
2281
|
-
const headers = AxiosHeaders.from(context.headers);
|
2325
|
+
const headers = AxiosHeaders$2.from(context.headers);
|
2282
2326
|
let data = context.data;
|
2283
2327
|
|
2284
2328
|
utils.forEach(fns, function transform(fn) {
|
@@ -2290,7 +2334,7 @@ function transformData(fns, response) {
|
|
2290
2334
|
return data;
|
2291
2335
|
}
|
2292
2336
|
|
2293
|
-
function isCancel(value) {
|
2337
|
+
function isCancel$1(value) {
|
2294
2338
|
return !!(value && value.__CANCEL__);
|
2295
2339
|
}
|
2296
2340
|
|
@@ -2307,7 +2351,7 @@ function throwIfCancellationRequested(config) {
|
|
2307
2351
|
}
|
2308
2352
|
|
2309
2353
|
if (config.signal && config.signal.aborted) {
|
2310
|
-
throw new CanceledError();
|
2354
|
+
throw new CanceledError$1();
|
2311
2355
|
}
|
2312
2356
|
}
|
2313
2357
|
|
@@ -2321,7 +2365,7 @@ function throwIfCancellationRequested(config) {
|
|
2321
2365
|
function dispatchRequest(config) {
|
2322
2366
|
throwIfCancellationRequested(config);
|
2323
2367
|
|
2324
|
-
config.headers = AxiosHeaders.from(config.headers);
|
2368
|
+
config.headers = AxiosHeaders$2.from(config.headers);
|
2325
2369
|
|
2326
2370
|
// Transform request data
|
2327
2371
|
config.data = transformData.call(
|
@@ -2329,7 +2373,11 @@ function dispatchRequest(config) {
|
|
2329
2373
|
config.transformRequest
|
2330
2374
|
);
|
2331
2375
|
|
2332
|
-
|
2376
|
+
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
2377
|
+
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
2378
|
+
}
|
2379
|
+
|
2380
|
+
const adapter = config.adapter || defaults$1.adapter;
|
2333
2381
|
|
2334
2382
|
return adapter(config).then(function onAdapterResolution(response) {
|
2335
2383
|
throwIfCancellationRequested(config);
|
@@ -2341,11 +2389,11 @@ function dispatchRequest(config) {
|
|
2341
2389
|
response
|
2342
2390
|
);
|
2343
2391
|
|
2344
|
-
response.headers = AxiosHeaders.from(response.headers);
|
2392
|
+
response.headers = AxiosHeaders$2.from(response.headers);
|
2345
2393
|
|
2346
2394
|
return response;
|
2347
2395
|
}, function onAdapterRejection(reason) {
|
2348
|
-
if (!isCancel(reason)) {
|
2396
|
+
if (!isCancel$1(reason)) {
|
2349
2397
|
throwIfCancellationRequested(config);
|
2350
2398
|
|
2351
2399
|
// Transform response data
|
@@ -2355,7 +2403,7 @@ function dispatchRequest(config) {
|
|
2355
2403
|
config.transformResponse,
|
2356
2404
|
reason.response
|
2357
2405
|
);
|
2358
|
-
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
2406
|
+
reason.response.headers = AxiosHeaders$2.from(reason.response.headers);
|
2359
2407
|
}
|
2360
2408
|
}
|
2361
2409
|
|
@@ -2363,6 +2411,8 @@ function dispatchRequest(config) {
|
|
2363
2411
|
});
|
2364
2412
|
}
|
2365
2413
|
|
2414
|
+
const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? thing.toJSON() : thing;
|
2415
|
+
|
2366
2416
|
/**
|
2367
2417
|
* Config-specific merge-function which creates a new config-object
|
2368
2418
|
* by merging two configuration objects together.
|
@@ -2377,9 +2427,9 @@ function mergeConfig(config1, config2) {
|
|
2377
2427
|
config2 = config2 || {};
|
2378
2428
|
const config = {};
|
2379
2429
|
|
2380
|
-
function getMergedValue(target, source) {
|
2430
|
+
function getMergedValue(target, source, caseless) {
|
2381
2431
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
2382
|
-
return utils.merge(target, source);
|
2432
|
+
return utils.merge.call({caseless}, target, source);
|
2383
2433
|
} else if (utils.isPlainObject(source)) {
|
2384
2434
|
return utils.merge({}, source);
|
2385
2435
|
} else if (utils.isArray(source)) {
|
@@ -2389,79 +2439,80 @@ function mergeConfig(config1, config2) {
|
|
2389
2439
|
}
|
2390
2440
|
|
2391
2441
|
// eslint-disable-next-line consistent-return
|
2392
|
-
function mergeDeepProperties(
|
2393
|
-
if (!utils.isUndefined(
|
2394
|
-
return getMergedValue(
|
2395
|
-
} else if (!utils.isUndefined(
|
2396
|
-
return getMergedValue(undefined,
|
2442
|
+
function mergeDeepProperties(a, b, caseless) {
|
2443
|
+
if (!utils.isUndefined(b)) {
|
2444
|
+
return getMergedValue(a, b, caseless);
|
2445
|
+
} else if (!utils.isUndefined(a)) {
|
2446
|
+
return getMergedValue(undefined, a, caseless);
|
2397
2447
|
}
|
2398
2448
|
}
|
2399
2449
|
|
2400
2450
|
// eslint-disable-next-line consistent-return
|
2401
|
-
function valueFromConfig2(
|
2402
|
-
if (!utils.isUndefined(
|
2403
|
-
return getMergedValue(undefined,
|
2451
|
+
function valueFromConfig2(a, b) {
|
2452
|
+
if (!utils.isUndefined(b)) {
|
2453
|
+
return getMergedValue(undefined, b);
|
2404
2454
|
}
|
2405
2455
|
}
|
2406
2456
|
|
2407
2457
|
// eslint-disable-next-line consistent-return
|
2408
|
-
function defaultToConfig2(
|
2409
|
-
if (!utils.isUndefined(
|
2410
|
-
return getMergedValue(undefined,
|
2411
|
-
} else if (!utils.isUndefined(
|
2412
|
-
return getMergedValue(undefined,
|
2458
|
+
function defaultToConfig2(a, b) {
|
2459
|
+
if (!utils.isUndefined(b)) {
|
2460
|
+
return getMergedValue(undefined, b);
|
2461
|
+
} else if (!utils.isUndefined(a)) {
|
2462
|
+
return getMergedValue(undefined, a);
|
2413
2463
|
}
|
2414
2464
|
}
|
2415
2465
|
|
2416
2466
|
// eslint-disable-next-line consistent-return
|
2417
|
-
function mergeDirectKeys(prop) {
|
2467
|
+
function mergeDirectKeys(a, b, prop) {
|
2418
2468
|
if (prop in config2) {
|
2419
|
-
return getMergedValue(
|
2469
|
+
return getMergedValue(a, b);
|
2420
2470
|
} else if (prop in config1) {
|
2421
|
-
return getMergedValue(undefined,
|
2471
|
+
return getMergedValue(undefined, a);
|
2422
2472
|
}
|
2423
2473
|
}
|
2424
2474
|
|
2425
2475
|
const mergeMap = {
|
2426
|
-
|
2427
|
-
|
2428
|
-
|
2429
|
-
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2476
|
+
url: valueFromConfig2,
|
2477
|
+
method: valueFromConfig2,
|
2478
|
+
data: valueFromConfig2,
|
2479
|
+
baseURL: defaultToConfig2,
|
2480
|
+
transformRequest: defaultToConfig2,
|
2481
|
+
transformResponse: defaultToConfig2,
|
2482
|
+
paramsSerializer: defaultToConfig2,
|
2483
|
+
timeout: defaultToConfig2,
|
2484
|
+
timeoutMessage: defaultToConfig2,
|
2485
|
+
withCredentials: defaultToConfig2,
|
2486
|
+
adapter: defaultToConfig2,
|
2487
|
+
responseType: defaultToConfig2,
|
2488
|
+
xsrfCookieName: defaultToConfig2,
|
2489
|
+
xsrfHeaderName: defaultToConfig2,
|
2490
|
+
onUploadProgress: defaultToConfig2,
|
2491
|
+
onDownloadProgress: defaultToConfig2,
|
2492
|
+
decompress: defaultToConfig2,
|
2493
|
+
maxContentLength: defaultToConfig2,
|
2494
|
+
maxBodyLength: defaultToConfig2,
|
2495
|
+
beforeRedirect: defaultToConfig2,
|
2496
|
+
transport: defaultToConfig2,
|
2497
|
+
httpAgent: defaultToConfig2,
|
2498
|
+
httpsAgent: defaultToConfig2,
|
2499
|
+
cancelToken: defaultToConfig2,
|
2500
|
+
socketPath: defaultToConfig2,
|
2501
|
+
responseEncoding: defaultToConfig2,
|
2502
|
+
validateStatus: mergeDirectKeys,
|
2503
|
+
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
2453
2504
|
};
|
2454
2505
|
|
2455
2506
|
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
2456
2507
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
2457
|
-
const configValue = merge(prop);
|
2508
|
+
const configValue = merge(config1[prop], config2[prop], prop);
|
2458
2509
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
2459
2510
|
});
|
2460
2511
|
|
2461
2512
|
return config;
|
2462
2513
|
}
|
2463
2514
|
|
2464
|
-
const VERSION = "1.1
|
2515
|
+
const VERSION$1 = "1.2.0-alpha.1";
|
2465
2516
|
|
2466
2517
|
const validators$1 = {};
|
2467
2518
|
|
@@ -2485,15 +2536,15 @@ const deprecatedWarnings = {};
|
|
2485
2536
|
*/
|
2486
2537
|
validators$1.transitional = function transitional(validator, version, message) {
|
2487
2538
|
function formatMessage(opt, desc) {
|
2488
|
-
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
2539
|
+
return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
2489
2540
|
}
|
2490
2541
|
|
2491
2542
|
// eslint-disable-next-line func-names
|
2492
2543
|
return (value, opt, opts) => {
|
2493
2544
|
if (validator === false) {
|
2494
|
-
throw new AxiosError(
|
2545
|
+
throw new AxiosError$1(
|
2495
2546
|
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
2496
|
-
AxiosError.ERR_DEPRECATED
|
2547
|
+
AxiosError$1.ERR_DEPRECATED
|
2497
2548
|
);
|
2498
2549
|
}
|
2499
2550
|
|
@@ -2524,7 +2575,7 @@ validators$1.transitional = function transitional(validator, version, message) {
|
|
2524
2575
|
|
2525
2576
|
function assertOptions(options, schema, allowUnknown) {
|
2526
2577
|
if (typeof options !== 'object') {
|
2527
|
-
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
2578
|
+
throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
|
2528
2579
|
}
|
2529
2580
|
const keys = Object.keys(options);
|
2530
2581
|
let i = keys.length;
|
@@ -2535,12 +2586,12 @@ function assertOptions(options, schema, allowUnknown) {
|
|
2535
2586
|
const value = options[opt];
|
2536
2587
|
const result = value === undefined || validator(value, opt, options);
|
2537
2588
|
if (result !== true) {
|
2538
|
-
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
2589
|
+
throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
|
2539
2590
|
}
|
2540
2591
|
continue;
|
2541
2592
|
}
|
2542
2593
|
if (allowUnknown !== true) {
|
2543
|
-
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
|
2594
|
+
throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
|
2544
2595
|
}
|
2545
2596
|
}
|
2546
2597
|
}
|
@@ -2559,12 +2610,12 @@ const validators = validator.validators;
|
|
2559
2610
|
*
|
2560
2611
|
* @return {Axios} A new instance of Axios
|
2561
2612
|
*/
|
2562
|
-
class Axios {
|
2613
|
+
class Axios$1 {
|
2563
2614
|
constructor(instanceConfig) {
|
2564
2615
|
this.defaults = instanceConfig;
|
2565
2616
|
this.interceptors = {
|
2566
|
-
request: new InterceptorManager(),
|
2567
|
-
response: new InterceptorManager()
|
2617
|
+
request: new InterceptorManager$1(),
|
2618
|
+
response: new InterceptorManager$1()
|
2568
2619
|
};
|
2569
2620
|
}
|
2570
2621
|
|
@@ -2588,7 +2639,7 @@ class Axios {
|
|
2588
2639
|
|
2589
2640
|
config = mergeConfig(this.defaults, config);
|
2590
2641
|
|
2591
|
-
const transitional = config
|
2642
|
+
const {transitional, paramsSerializer, headers} = config;
|
2592
2643
|
|
2593
2644
|
if (transitional !== undefined) {
|
2594
2645
|
validator.assertOptions(transitional, {
|
@@ -2598,23 +2649,32 @@ class Axios {
|
|
2598
2649
|
}, false);
|
2599
2650
|
}
|
2600
2651
|
|
2652
|
+
if (paramsSerializer !== undefined) {
|
2653
|
+
validator.assertOptions(paramsSerializer, {
|
2654
|
+
encode: validators.function,
|
2655
|
+
serialize: validators.function
|
2656
|
+
}, true);
|
2657
|
+
}
|
2658
|
+
|
2601
2659
|
// Set config.method
|
2602
2660
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
2603
2661
|
|
2662
|
+
let contextHeaders;
|
2663
|
+
|
2604
2664
|
// Flatten headers
|
2605
|
-
|
2606
|
-
|
2607
|
-
|
2665
|
+
contextHeaders = headers && utils.merge(
|
2666
|
+
headers.common,
|
2667
|
+
headers[config.method]
|
2608
2668
|
);
|
2609
2669
|
|
2610
|
-
|
2670
|
+
contextHeaders && utils.forEach(
|
2611
2671
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
2612
|
-
|
2613
|
-
delete
|
2672
|
+
(method) => {
|
2673
|
+
delete headers[method];
|
2614
2674
|
}
|
2615
2675
|
);
|
2616
2676
|
|
2617
|
-
config.headers =
|
2677
|
+
config.headers = AxiosHeaders$2.concat(contextHeaders, headers);
|
2618
2678
|
|
2619
2679
|
// filter out skipped interceptors
|
2620
2680
|
const requestInterceptorChain = [];
|
@@ -2696,7 +2756,7 @@ class Axios {
|
|
2696
2756
|
// Provide aliases for supported request methods
|
2697
2757
|
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
2698
2758
|
/*eslint func-names:0*/
|
2699
|
-
Axios.prototype[method] = function(url, config) {
|
2759
|
+
Axios$1.prototype[method] = function(url, config) {
|
2700
2760
|
return this.request(mergeConfig(config || {}, {
|
2701
2761
|
method,
|
2702
2762
|
url,
|
@@ -2721,11 +2781,13 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2721
2781
|
};
|
2722
2782
|
}
|
2723
2783
|
|
2724
|
-
Axios.prototype[method] = generateHTTPMethod();
|
2784
|
+
Axios$1.prototype[method] = generateHTTPMethod();
|
2725
2785
|
|
2726
|
-
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
2786
|
+
Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
|
2727
2787
|
});
|
2728
2788
|
|
2789
|
+
const Axios$2 = Axios$1;
|
2790
|
+
|
2729
2791
|
/**
|
2730
2792
|
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
2731
2793
|
*
|
@@ -2733,7 +2795,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2733
2795
|
*
|
2734
2796
|
* @returns {CancelToken}
|
2735
2797
|
*/
|
2736
|
-
class CancelToken {
|
2798
|
+
class CancelToken$1 {
|
2737
2799
|
constructor(executor) {
|
2738
2800
|
if (typeof executor !== 'function') {
|
2739
2801
|
throw new TypeError('executor must be a function.');
|
@@ -2781,7 +2843,7 @@ class CancelToken {
|
|
2781
2843
|
return;
|
2782
2844
|
}
|
2783
2845
|
|
2784
|
-
token.reason = new CanceledError(message, config, request);
|
2846
|
+
token.reason = new CanceledError$1(message, config, request);
|
2785
2847
|
resolvePromise(token.reason);
|
2786
2848
|
});
|
2787
2849
|
}
|
@@ -2832,7 +2894,7 @@ class CancelToken {
|
|
2832
2894
|
*/
|
2833
2895
|
static source() {
|
2834
2896
|
let cancel;
|
2835
|
-
const token = new CancelToken(function executor(c) {
|
2897
|
+
const token = new CancelToken$1(function executor(c) {
|
2836
2898
|
cancel = c;
|
2837
2899
|
});
|
2838
2900
|
return {
|
@@ -2842,6 +2904,8 @@ class CancelToken {
|
|
2842
2904
|
}
|
2843
2905
|
}
|
2844
2906
|
|
2907
|
+
const CancelToken$2 = CancelToken$1;
|
2908
|
+
|
2845
2909
|
/**
|
2846
2910
|
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
2847
2911
|
*
|
@@ -2863,7 +2927,7 @@ class CancelToken {
|
|
2863
2927
|
*
|
2864
2928
|
* @returns {Function}
|
2865
2929
|
*/
|
2866
|
-
function spread(callback) {
|
2930
|
+
function spread$1(callback) {
|
2867
2931
|
return function wrap(arr) {
|
2868
2932
|
return callback.apply(null, arr);
|
2869
2933
|
};
|
@@ -2876,7 +2940,7 @@ function spread(callback) {
|
|
2876
2940
|
*
|
2877
2941
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
2878
2942
|
*/
|
2879
|
-
function isAxiosError(payload) {
|
2943
|
+
function isAxiosError$1(payload) {
|
2880
2944
|
return utils.isObject(payload) && (payload.isAxiosError === true);
|
2881
2945
|
}
|
2882
2946
|
|
@@ -2888,11 +2952,11 @@ function isAxiosError(payload) {
|
|
2888
2952
|
* @returns {Axios} A new instance of Axios
|
2889
2953
|
*/
|
2890
2954
|
function createInstance(defaultConfig) {
|
2891
|
-
const context = new Axios(defaultConfig);
|
2892
|
-
const instance = bind(Axios.prototype.request, context);
|
2955
|
+
const context = new Axios$2(defaultConfig);
|
2956
|
+
const instance = bind(Axios$2.prototype.request, context);
|
2893
2957
|
|
2894
2958
|
// Copy axios.prototype to instance
|
2895
|
-
utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});
|
2959
|
+
utils.extend(instance, Axios$2.prototype, context, {allOwnKeys: true});
|
2896
2960
|
|
2897
2961
|
// Copy context to instance
|
2898
2962
|
utils.extend(instance, context, null, {allOwnKeys: true});
|
@@ -2906,20 +2970,20 @@ function createInstance(defaultConfig) {
|
|
2906
2970
|
}
|
2907
2971
|
|
2908
2972
|
// Create the default instance to be exported
|
2909
|
-
const axios = createInstance(defaults);
|
2973
|
+
const axios = createInstance(defaults$1);
|
2910
2974
|
|
2911
2975
|
// Expose Axios class to allow class inheritance
|
2912
|
-
axios.Axios = Axios;
|
2976
|
+
axios.Axios = Axios$2;
|
2913
2977
|
|
2914
2978
|
// Expose Cancel & CancelToken
|
2915
|
-
axios.CanceledError = CanceledError;
|
2916
|
-
axios.CancelToken = CancelToken;
|
2917
|
-
axios.isCancel = isCancel;
|
2918
|
-
axios.VERSION = VERSION;
|
2919
|
-
axios.toFormData = toFormData;
|
2979
|
+
axios.CanceledError = CanceledError$1;
|
2980
|
+
axios.CancelToken = CancelToken$2;
|
2981
|
+
axios.isCancel = isCancel$1;
|
2982
|
+
axios.VERSION = VERSION$1;
|
2983
|
+
axios.toFormData = toFormData$1;
|
2920
2984
|
|
2921
2985
|
// Expose AxiosError class
|
2922
|
-
axios.AxiosError = AxiosError;
|
2986
|
+
axios.AxiosError = AxiosError$1;
|
2923
2987
|
|
2924
2988
|
// alias for CanceledError for backward compatibility
|
2925
2989
|
axios.Cancel = axios.CanceledError;
|
@@ -2929,14 +2993,38 @@ axios.all = function all(promises) {
|
|
2929
2993
|
return Promise.all(promises);
|
2930
2994
|
};
|
2931
2995
|
|
2932
|
-
axios.spread = spread;
|
2996
|
+
axios.spread = spread$1;
|
2933
2997
|
|
2934
2998
|
// Expose isAxiosError
|
2935
|
-
axios.isAxiosError = isAxiosError;
|
2936
|
-
|
2937
|
-
axios.
|
2938
|
-
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2999
|
+
axios.isAxiosError = isAxiosError$1;
|
3000
|
+
|
3001
|
+
axios.AxiosHeaders = AxiosHeaders$2;
|
3002
|
+
|
3003
|
+
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
3004
|
+
|
3005
|
+
axios.default = axios;
|
3006
|
+
|
3007
|
+
// this module should only have a default export
|
3008
|
+
const axios$1 = axios;
|
3009
|
+
|
3010
|
+
// This module is intended to unwrap Axios default export as named.
|
3011
|
+
// Keep top-level export same with static properties
|
3012
|
+
// so that it can keep same with es module or cjs
|
3013
|
+
const {
|
3014
|
+
Axios,
|
3015
|
+
AxiosError,
|
3016
|
+
CanceledError,
|
3017
|
+
isCancel,
|
3018
|
+
CancelToken,
|
3019
|
+
VERSION,
|
3020
|
+
all,
|
3021
|
+
Cancel,
|
3022
|
+
isAxiosError,
|
3023
|
+
spread,
|
3024
|
+
toFormData,
|
3025
|
+
AxiosHeaders,
|
3026
|
+
formToJSON
|
3027
|
+
} = axios$1;
|
3028
|
+
|
3029
|
+
export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, spread, toFormData };
|
2942
3030
|
//# sourceMappingURL=axios.js.map
|