axios 1.1.3 → 1.3.4
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 +312 -75
- package/{UPGRADE_GUIDE.md → MIGRATION_GUIDE.md} +1 -1
- package/README.md +64 -25
- package/dist/axios.js +888 -582
- 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 +3191 -0
- package/dist/browser/axios.cjs.map +1 -0
- package/dist/esm/axios.js +889 -626
- 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 +1001 -575
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +528 -0
- package/index.d.ts +116 -56
- package/index.js +12 -3
- package/lib/adapters/adapters.js +59 -0
- package/lib/adapters/http.js +118 -57
- package/lib/adapters/xhr.js +7 -4
- package/lib/axios.js +13 -3
- package/lib/core/Axios.js +10 -8
- package/lib/core/AxiosError.js +1 -1
- package/lib/core/AxiosHeaders.js +102 -80
- package/lib/core/dispatchRequest.js +7 -2
- package/lib/core/mergeConfig.js +50 -46
- package/lib/defaults/index.js +2 -21
- package/lib/env/classes/FormData.js +2 -2
- package/lib/env/data.js +1 -1
- package/lib/helpers/HttpStatusCode.js +71 -0
- package/lib/helpers/ZlibHeaderTransformStream.js +28 -0
- package/lib/helpers/formDataToStream.js +111 -0
- package/lib/helpers/readBlob.js +15 -0
- package/lib/helpers/speedometer.js +1 -1
- package/lib/helpers/toFormData.js +5 -15
- package/lib/platform/browser/classes/Blob.js +3 -0
- package/lib/platform/browser/classes/FormData.js +1 -1
- package/lib/platform/browser/index.js +21 -0
- package/lib/utils.js +107 -9
- package/package.json +86 -14
- package/bin/ssl_hotfix.js +0 -22
- package/gulpfile.js +0 -88
- package/karma.conf.cjs +0 -250
- package/lib/adapters/index.js +0 -33
- package/rollup.config.js +0 -90
- package/tsconfig.json +0 -14
- package/tslint.json +0 -6
package/dist/axios.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.
|
1
|
+
// Axios v1.3.4 Copyright (c) 2023 Matt Zabriskie and contributors
|
2
2
|
(function (global, factory) {
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
@@ -36,6 +36,52 @@
|
|
36
36
|
});
|
37
37
|
return Constructor;
|
38
38
|
}
|
39
|
+
function _slicedToArray(arr, i) {
|
40
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
41
|
+
}
|
42
|
+
function _arrayWithHoles(arr) {
|
43
|
+
if (Array.isArray(arr)) return arr;
|
44
|
+
}
|
45
|
+
function _iterableToArrayLimit(arr, i) {
|
46
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
47
|
+
if (_i == null) return;
|
48
|
+
var _arr = [];
|
49
|
+
var _n = true;
|
50
|
+
var _d = false;
|
51
|
+
var _s, _e;
|
52
|
+
try {
|
53
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
54
|
+
_arr.push(_s.value);
|
55
|
+
if (i && _arr.length === i) break;
|
56
|
+
}
|
57
|
+
} catch (err) {
|
58
|
+
_d = true;
|
59
|
+
_e = err;
|
60
|
+
} finally {
|
61
|
+
try {
|
62
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
63
|
+
} finally {
|
64
|
+
if (_d) throw _e;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
return _arr;
|
68
|
+
}
|
69
|
+
function _unsupportedIterableToArray(o, minLen) {
|
70
|
+
if (!o) return;
|
71
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
72
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
73
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
74
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
75
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
76
|
+
}
|
77
|
+
function _arrayLikeToArray(arr, len) {
|
78
|
+
if (len == null || len > arr.length) len = arr.length;
|
79
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
80
|
+
return arr2;
|
81
|
+
}
|
82
|
+
function _nonIterableRest() {
|
83
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
84
|
+
}
|
39
85
|
|
40
86
|
function bind(fn, thisArg) {
|
41
87
|
return function wrap() {
|
@@ -274,7 +320,7 @@
|
|
274
320
|
* @param {Function} fn The callback to invoke for each item
|
275
321
|
*
|
276
322
|
* @param {Boolean} [allOwnKeys = false]
|
277
|
-
* @returns {
|
323
|
+
* @returns {any}
|
278
324
|
*/
|
279
325
|
function forEach(obj, fn) {
|
280
326
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
@@ -308,6 +354,27 @@
|
|
308
354
|
}
|
309
355
|
}
|
310
356
|
}
|
357
|
+
function findKey(obj, key) {
|
358
|
+
key = key.toLowerCase();
|
359
|
+
var keys = Object.keys(obj);
|
360
|
+
var i = keys.length;
|
361
|
+
var _key;
|
362
|
+
while (i-- > 0) {
|
363
|
+
_key = keys[i];
|
364
|
+
if (key === _key.toLowerCase()) {
|
365
|
+
return _key;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
return null;
|
369
|
+
}
|
370
|
+
var _global = function () {
|
371
|
+
/*eslint no-undef:0*/
|
372
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
373
|
+
return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
|
374
|
+
}();
|
375
|
+
var isContextDefined = function isContextDefined(context) {
|
376
|
+
return !isUndefined(context) && context !== _global;
|
377
|
+
};
|
311
378
|
|
312
379
|
/**
|
313
380
|
* Accepts varargs expecting each argument to be an object, then
|
@@ -329,16 +396,19 @@
|
|
329
396
|
*/
|
330
397
|
function /* obj1, obj2, obj3, ... */
|
331
398
|
merge() {
|
399
|
+
var _ref2 = isContextDefined(this) && this || {},
|
400
|
+
caseless = _ref2.caseless;
|
332
401
|
var result = {};
|
333
402
|
var assignValue = function assignValue(val, key) {
|
334
|
-
|
335
|
-
|
403
|
+
var targetKey = caseless && findKey(result, key) || key;
|
404
|
+
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
405
|
+
result[targetKey] = merge(result[targetKey], val);
|
336
406
|
} else if (isPlainObject(val)) {
|
337
|
-
result[
|
407
|
+
result[targetKey] = merge({}, val);
|
338
408
|
} else if (isArray(val)) {
|
339
|
-
result[
|
409
|
+
result[targetKey] = val.slice();
|
340
410
|
} else {
|
341
|
-
result[
|
411
|
+
result[targetKey] = val;
|
342
412
|
}
|
343
413
|
};
|
344
414
|
for (var i = 0, l = arguments.length; i < l; i++) {
|
@@ -358,8 +428,8 @@
|
|
358
428
|
* @returns {Object} The resulting value of object a
|
359
429
|
*/
|
360
430
|
var extend = function extend(a, b, thisArg) {
|
361
|
-
var
|
362
|
-
allOwnKeys =
|
431
|
+
var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
432
|
+
allOwnKeys = _ref3.allOwnKeys;
|
363
433
|
forEach(b, function (val, key) {
|
364
434
|
if (thisArg && isFunction(val)) {
|
365
435
|
a[key] = bind(val, thisArg);
|
@@ -528,14 +598,14 @@
|
|
528
598
|
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
529
599
|
var isHTMLForm = kindOfTest('HTMLFormElement');
|
530
600
|
var toCamelCase = function toCamelCase(str) {
|
531
|
-
return str.toLowerCase().replace(/[_
|
601
|
+
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
532
602
|
return p1.toUpperCase() + p2;
|
533
603
|
});
|
534
604
|
};
|
535
605
|
|
536
606
|
/* Creating a function that will check if an object has a property. */
|
537
|
-
var hasOwnProperty = function (
|
538
|
-
var hasOwnProperty =
|
607
|
+
var hasOwnProperty = function (_ref4) {
|
608
|
+
var hasOwnProperty = _ref4.hasOwnProperty;
|
539
609
|
return function (obj, prop) {
|
540
610
|
return hasOwnProperty.call(obj, prop);
|
541
611
|
};
|
@@ -567,6 +637,10 @@
|
|
567
637
|
|
568
638
|
var freezeMethods = function freezeMethods(obj) {
|
569
639
|
reduceDescriptors(obj, function (descriptor, name) {
|
640
|
+
// skip restricted props in strict mode
|
641
|
+
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
642
|
+
return false;
|
643
|
+
}
|
570
644
|
var value = obj[name];
|
571
645
|
if (!isFunction(value)) return;
|
572
646
|
descriptor.enumerable = false;
|
@@ -576,7 +650,7 @@
|
|
576
650
|
}
|
577
651
|
if (!descriptor.set) {
|
578
652
|
descriptor.set = function () {
|
579
|
-
throw Error('Can not read-only method \'' + name + '\'');
|
653
|
+
throw Error('Can not rewrite read-only method \'' + name + '\'');
|
580
654
|
};
|
581
655
|
}
|
582
656
|
});
|
@@ -596,6 +670,56 @@
|
|
596
670
|
value = +value;
|
597
671
|
return Number.isFinite(value) ? value : defaultValue;
|
598
672
|
};
|
673
|
+
var ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
674
|
+
var DIGIT = '0123456789';
|
675
|
+
var ALPHABET = {
|
676
|
+
DIGIT: DIGIT,
|
677
|
+
ALPHA: ALPHA,
|
678
|
+
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
679
|
+
};
|
680
|
+
var generateString = function generateString() {
|
681
|
+
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
|
682
|
+
var alphabet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ALPHABET.ALPHA_DIGIT;
|
683
|
+
var str = '';
|
684
|
+
var length = alphabet.length;
|
685
|
+
while (size--) {
|
686
|
+
str += alphabet[Math.random() * length | 0];
|
687
|
+
}
|
688
|
+
return str;
|
689
|
+
};
|
690
|
+
|
691
|
+
/**
|
692
|
+
* If the thing is a FormData object, return true, otherwise return false.
|
693
|
+
*
|
694
|
+
* @param {unknown} thing - The thing to check.
|
695
|
+
*
|
696
|
+
* @returns {boolean}
|
697
|
+
*/
|
698
|
+
function isSpecCompliantForm(thing) {
|
699
|
+
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
700
|
+
}
|
701
|
+
var toJSONObject = function toJSONObject(obj) {
|
702
|
+
var stack = new Array(10);
|
703
|
+
var visit = function visit(source, i) {
|
704
|
+
if (isObject(source)) {
|
705
|
+
if (stack.indexOf(source) >= 0) {
|
706
|
+
return;
|
707
|
+
}
|
708
|
+
if (!('toJSON' in source)) {
|
709
|
+
stack[i] = source;
|
710
|
+
var target = isArray(source) ? [] : {};
|
711
|
+
forEach(source, function (value, key) {
|
712
|
+
var reducedValue = visit(value, i + 1);
|
713
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
714
|
+
});
|
715
|
+
stack[i] = undefined;
|
716
|
+
return target;
|
717
|
+
}
|
718
|
+
}
|
719
|
+
return source;
|
720
|
+
};
|
721
|
+
return visit(obj, 0);
|
722
|
+
};
|
599
723
|
var utils = {
|
600
724
|
isArray: isArray,
|
601
725
|
isArrayBuffer: isArrayBuffer,
|
@@ -639,7 +763,14 @@
|
|
639
763
|
toObjectSet: toObjectSet,
|
640
764
|
toCamelCase: toCamelCase,
|
641
765
|
noop: noop,
|
642
|
-
toFiniteNumber: toFiniteNumber
|
766
|
+
toFiniteNumber: toFiniteNumber,
|
767
|
+
findKey: findKey,
|
768
|
+
global: _global,
|
769
|
+
isContextDefined: isContextDefined,
|
770
|
+
ALPHABET: ALPHABET,
|
771
|
+
generateString: generateString,
|
772
|
+
isSpecCompliantForm: isSpecCompliantForm,
|
773
|
+
toJSONObject: toJSONObject
|
643
774
|
};
|
644
775
|
|
645
776
|
/**
|
@@ -682,7 +813,7 @@
|
|
682
813
|
columnNumber: this.columnNumber,
|
683
814
|
stack: this.stack,
|
684
815
|
// Axios
|
685
|
-
config: this.config,
|
816
|
+
config: utils.toJSONObject(this.config),
|
686
817
|
code: this.code,
|
687
818
|
status: this.response && this.response.status ? this.response.status : null
|
688
819
|
};
|
@@ -717,8 +848,8 @@
|
|
717
848
|
return axiosError;
|
718
849
|
};
|
719
850
|
|
720
|
-
|
721
|
-
var
|
851
|
+
// eslint-disable-next-line strict
|
852
|
+
var httpAdapter = null;
|
722
853
|
|
723
854
|
/**
|
724
855
|
* Determines if the given thing is a array or js object.
|
@@ -774,17 +905,6 @@
|
|
774
905
|
return /^is[A-Z]/.test(prop);
|
775
906
|
});
|
776
907
|
|
777
|
-
/**
|
778
|
-
* If the thing is a FormData object, return true, otherwise return false.
|
779
|
-
*
|
780
|
-
* @param {unknown} thing - The thing to check.
|
781
|
-
*
|
782
|
-
* @returns {boolean}
|
783
|
-
*/
|
784
|
-
function isSpecCompliant(thing) {
|
785
|
-
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
786
|
-
}
|
787
|
-
|
788
908
|
/**
|
789
909
|
* Convert a data object to FormData
|
790
910
|
*
|
@@ -814,7 +934,7 @@
|
|
814
934
|
}
|
815
935
|
|
816
936
|
// eslint-disable-next-line no-param-reassign
|
817
|
-
formData = formData || new (
|
937
|
+
formData = formData || new (FormData)();
|
818
938
|
|
819
939
|
// eslint-disable-next-line no-param-reassign
|
820
940
|
options = utils.toFlatObject(options, {
|
@@ -831,7 +951,7 @@
|
|
831
951
|
var dots = options.dots;
|
832
952
|
var indexes = options.indexes;
|
833
953
|
var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
834
|
-
var useBlob = _Blob &&
|
954
|
+
var useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
835
955
|
if (!utils.isFunction(visitor)) {
|
836
956
|
throw new TypeError('visitor must be a function');
|
837
957
|
}
|
@@ -867,7 +987,7 @@
|
|
867
987
|
key = metaTokens ? key : key.slice(0, -2);
|
868
988
|
// eslint-disable-next-line no-param-reassign
|
869
989
|
value = JSON.stringify(value);
|
870
|
-
} else if (utils.isArray(value) && isFlatArray(value) || utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
|
990
|
+
} else if (utils.isArray(value) && isFlatArray(value) || (utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))) {
|
871
991
|
// eslint-disable-next-line no-param-reassign
|
872
992
|
key = removeBrackets(key);
|
873
993
|
arr.forEach(function each(el, index) {
|
@@ -1079,6 +1199,7 @@
|
|
1079
1199
|
}]);
|
1080
1200
|
return InterceptorManager;
|
1081
1201
|
}();
|
1202
|
+
var InterceptorManager$1 = InterceptorManager;
|
1082
1203
|
|
1083
1204
|
var transitionalDefaults = {
|
1084
1205
|
silentJSONParsing: true,
|
@@ -1088,7 +1209,9 @@
|
|
1088
1209
|
|
1089
1210
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
1090
1211
|
|
1091
|
-
var FormData$1 = FormData;
|
1212
|
+
var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
1213
|
+
|
1214
|
+
var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
1092
1215
|
|
1093
1216
|
/**
|
1094
1217
|
* Determine if we're running in a standard browser environment
|
@@ -1114,14 +1237,30 @@
|
|
1114
1237
|
}
|
1115
1238
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
1116
1239
|
}();
|
1240
|
+
|
1241
|
+
/**
|
1242
|
+
* Determine if we're running in a standard browser webWorker environment
|
1243
|
+
*
|
1244
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
1245
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
1246
|
+
* filtered out due to its judgment standard
|
1247
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
1248
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
1249
|
+
*/
|
1250
|
+
var isStandardBrowserWebWorkerEnv = function () {
|
1251
|
+
return typeof WorkerGlobalScope !== 'undefined' &&
|
1252
|
+
// eslint-disable-next-line no-undef
|
1253
|
+
self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
|
1254
|
+
}();
|
1117
1255
|
var platform = {
|
1118
1256
|
isBrowser: true,
|
1119
1257
|
classes: {
|
1120
1258
|
URLSearchParams: URLSearchParams$1,
|
1121
1259
|
FormData: FormData$1,
|
1122
|
-
Blob: Blob
|
1260
|
+
Blob: Blob$1
|
1123
1261
|
},
|
1124
1262
|
isStandardBrowserEnv: isStandardBrowserEnv,
|
1263
|
+
isStandardBrowserWebWorkerEnv: isStandardBrowserWebWorkerEnv,
|
1125
1264
|
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
1126
1265
|
};
|
1127
1266
|
|
@@ -1214,201 +1353,143 @@
|
|
1214
1353
|
return null;
|
1215
1354
|
}
|
1216
1355
|
|
1356
|
+
var DEFAULT_CONTENT_TYPE = {
|
1357
|
+
'Content-Type': undefined
|
1358
|
+
};
|
1359
|
+
|
1217
1360
|
/**
|
1218
|
-
*
|
1361
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
1362
|
+
* of the input
|
1219
1363
|
*
|
1220
|
-
* @param {
|
1221
|
-
* @param {Function}
|
1222
|
-
* @param {
|
1364
|
+
* @param {any} rawValue - The value to be stringified.
|
1365
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
1366
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
1223
1367
|
*
|
1224
|
-
* @returns {
|
1368
|
+
* @returns {string} A stringified version of the rawValue.
|
1225
1369
|
*/
|
1226
|
-
function
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1370
|
+
function stringifySafely(rawValue, parser, encoder) {
|
1371
|
+
if (utils.isString(rawValue)) {
|
1372
|
+
try {
|
1373
|
+
(parser || JSON.parse)(rawValue);
|
1374
|
+
return utils.trim(rawValue);
|
1375
|
+
} catch (e) {
|
1376
|
+
if (e.name !== 'SyntaxError') {
|
1377
|
+
throw e;
|
1378
|
+
}
|
1379
|
+
}
|
1232
1380
|
}
|
1381
|
+
return (encoder || JSON.stringify)(rawValue);
|
1233
1382
|
}
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1383
|
+
var defaults = {
|
1384
|
+
transitional: transitionalDefaults,
|
1385
|
+
adapter: ['xhr', 'http'],
|
1386
|
+
transformRequest: [function transformRequest(data, headers) {
|
1387
|
+
var contentType = headers.getContentType() || '';
|
1388
|
+
var hasJSONContentType = contentType.indexOf('application/json') > -1;
|
1389
|
+
var isObjectPayload = utils.isObject(data);
|
1390
|
+
if (isObjectPayload && utils.isHTMLForm(data)) {
|
1391
|
+
data = new FormData(data);
|
1392
|
+
}
|
1393
|
+
var isFormData = utils.isFormData(data);
|
1394
|
+
if (isFormData) {
|
1395
|
+
if (!hasJSONContentType) {
|
1396
|
+
return data;
|
1244
1397
|
}
|
1245
|
-
|
1246
|
-
|
1398
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
1399
|
+
}
|
1400
|
+
if (utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data)) {
|
1401
|
+
return data;
|
1402
|
+
}
|
1403
|
+
if (utils.isArrayBufferView(data)) {
|
1404
|
+
return data.buffer;
|
1405
|
+
}
|
1406
|
+
if (utils.isURLSearchParams(data)) {
|
1407
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
1408
|
+
return data.toString();
|
1409
|
+
}
|
1410
|
+
var isFileList;
|
1411
|
+
if (isObjectPayload) {
|
1412
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
1413
|
+
return toURLEncodedForm(data, this.formSerializer).toString();
|
1247
1414
|
}
|
1248
|
-
if (utils.
|
1249
|
-
|
1415
|
+
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
1416
|
+
var _FormData = this.env && this.env.FormData;
|
1417
|
+
return toFormData(isFileList ? {
|
1418
|
+
'files[]': data
|
1419
|
+
} : data, _FormData && new _FormData(), this.formSerializer);
|
1250
1420
|
}
|
1251
|
-
|
1252
|
-
|
1421
|
+
}
|
1422
|
+
if (isObjectPayload || hasJSONContentType) {
|
1423
|
+
headers.setContentType('application/json', false);
|
1424
|
+
return stringifySafely(data);
|
1425
|
+
}
|
1426
|
+
return data;
|
1427
|
+
}],
|
1428
|
+
transformResponse: [function transformResponse(data) {
|
1429
|
+
var transitional = this.transitional || defaults.transitional;
|
1430
|
+
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
1431
|
+
var JSONRequested = this.responseType === 'json';
|
1432
|
+
if (data && utils.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
1433
|
+
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
1434
|
+
var strictJSONParsing = !silentJSONParsing && JSONRequested;
|
1435
|
+
try {
|
1436
|
+
return JSON.parse(data);
|
1437
|
+
} catch (e) {
|
1438
|
+
if (strictJSONParsing) {
|
1439
|
+
if (e.name === 'SyntaxError') {
|
1440
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
1441
|
+
}
|
1442
|
+
throw e;
|
1443
|
+
}
|
1253
1444
|
}
|
1254
|
-
document.cookie = cookie.join('; ');
|
1255
|
-
},
|
1256
|
-
read: function read(name) {
|
1257
|
-
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
1258
|
-
return match ? decodeURIComponent(match[3]) : null;
|
1259
|
-
},
|
1260
|
-
remove: function remove(name) {
|
1261
|
-
this.write(name, '', Date.now() - 86400000);
|
1262
1445
|
}
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1446
|
+
return data;
|
1447
|
+
}],
|
1448
|
+
/**
|
1449
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
1450
|
+
* timeout is not created.
|
1451
|
+
*/
|
1452
|
+
timeout: 0,
|
1453
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
1454
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
1455
|
+
maxContentLength: -1,
|
1456
|
+
maxBodyLength: -1,
|
1457
|
+
env: {
|
1458
|
+
FormData: platform.classes.FormData,
|
1459
|
+
Blob: platform.classes.Blob
|
1460
|
+
},
|
1461
|
+
validateStatus: function validateStatus(status) {
|
1462
|
+
return status >= 200 && status < 300;
|
1463
|
+
},
|
1464
|
+
headers: {
|
1465
|
+
common: {
|
1466
|
+
'Accept': 'application/json, text/plain, */*'
|
1467
|
+
}
|
1468
|
+
}
|
1469
|
+
};
|
1470
|
+
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
1471
|
+
defaults.headers[method] = {};
|
1472
|
+
});
|
1473
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
1474
|
+
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
1475
|
+
});
|
1476
|
+
var defaults$1 = defaults;
|
1275
1477
|
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
* @param {string} url The URL to test
|
1280
|
-
*
|
1281
|
-
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
1282
|
-
*/
|
1283
|
-
function isAbsoluteURL(url) {
|
1284
|
-
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
1285
|
-
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
1286
|
-
// by any combination of letters, digits, plus, period, or hyphen.
|
1287
|
-
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
1288
|
-
}
|
1478
|
+
// RawAxiosHeaders whose duplicates are ignored by node
|
1479
|
+
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
1480
|
+
var ignoreDuplicateOf = utils.toObjectSet(['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent']);
|
1289
1481
|
|
1290
1482
|
/**
|
1291
|
-
*
|
1292
|
-
*
|
1293
|
-
* @param {string} baseURL The base URL
|
1294
|
-
* @param {string} relativeURL The relative URL
|
1483
|
+
* Parse headers into an object
|
1295
1484
|
*
|
1296
|
-
*
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
/**
|
1303
|
-
* Creates a new URL by combining the baseURL with the requestedURL,
|
1304
|
-
* only when the requestedURL is not already an absolute URL.
|
1305
|
-
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
1485
|
+
* ```
|
1486
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
1487
|
+
* Content-Type: application/json
|
1488
|
+
* Connection: keep-alive
|
1489
|
+
* Transfer-Encoding: chunked
|
1490
|
+
* ```
|
1306
1491
|
*
|
1307
|
-
* @param {
|
1308
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
1309
|
-
*
|
1310
|
-
* @returns {string} The combined full path
|
1311
|
-
*/
|
1312
|
-
function buildFullPath(baseURL, requestedURL) {
|
1313
|
-
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
1314
|
-
return combineURLs(baseURL, requestedURL);
|
1315
|
-
}
|
1316
|
-
return requestedURL;
|
1317
|
-
}
|
1318
|
-
|
1319
|
-
var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
1320
|
-
// Standard browser envs have full support of the APIs needed to test
|
1321
|
-
// whether the request URL is of the same origin as current location.
|
1322
|
-
function standardBrowserEnv() {
|
1323
|
-
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
1324
|
-
var urlParsingNode = document.createElement('a');
|
1325
|
-
var originURL;
|
1326
|
-
|
1327
|
-
/**
|
1328
|
-
* Parse a URL to discover it's components
|
1329
|
-
*
|
1330
|
-
* @param {String} url The URL to be parsed
|
1331
|
-
* @returns {Object}
|
1332
|
-
*/
|
1333
|
-
function resolveURL(url) {
|
1334
|
-
var href = url;
|
1335
|
-
if (msie) {
|
1336
|
-
// IE needs attribute set twice to normalize properties
|
1337
|
-
urlParsingNode.setAttribute('href', href);
|
1338
|
-
href = urlParsingNode.href;
|
1339
|
-
}
|
1340
|
-
urlParsingNode.setAttribute('href', href);
|
1341
|
-
|
1342
|
-
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
1343
|
-
return {
|
1344
|
-
href: urlParsingNode.href,
|
1345
|
-
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
1346
|
-
host: urlParsingNode.host,
|
1347
|
-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
1348
|
-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
1349
|
-
hostname: urlParsingNode.hostname,
|
1350
|
-
port: urlParsingNode.port,
|
1351
|
-
pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname
|
1352
|
-
};
|
1353
|
-
}
|
1354
|
-
originURL = resolveURL(window.location.href);
|
1355
|
-
|
1356
|
-
/**
|
1357
|
-
* Determine if a URL shares the same origin as the current location
|
1358
|
-
*
|
1359
|
-
* @param {String} requestURL The URL to test
|
1360
|
-
* @returns {boolean} True if URL shares the same origin, otherwise false
|
1361
|
-
*/
|
1362
|
-
return function isURLSameOrigin(requestURL) {
|
1363
|
-
var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
1364
|
-
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
1365
|
-
};
|
1366
|
-
}() :
|
1367
|
-
// Non standard browser envs (web workers, react-native) lack needed support.
|
1368
|
-
function nonStandardBrowserEnv() {
|
1369
|
-
return function isURLSameOrigin() {
|
1370
|
-
return true;
|
1371
|
-
};
|
1372
|
-
}();
|
1373
|
-
|
1374
|
-
/**
|
1375
|
-
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
1376
|
-
*
|
1377
|
-
* @param {string=} message The message.
|
1378
|
-
* @param {Object=} config The config.
|
1379
|
-
* @param {Object=} request The request.
|
1380
|
-
*
|
1381
|
-
* @returns {CanceledError} The created error.
|
1382
|
-
*/
|
1383
|
-
function CanceledError(message, config, request) {
|
1384
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
1385
|
-
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
1386
|
-
this.name = 'CanceledError';
|
1387
|
-
}
|
1388
|
-
utils.inherits(CanceledError, AxiosError, {
|
1389
|
-
__CANCEL__: true
|
1390
|
-
});
|
1391
|
-
|
1392
|
-
function parseProtocol(url) {
|
1393
|
-
var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
1394
|
-
return match && match[1] || '';
|
1395
|
-
}
|
1396
|
-
|
1397
|
-
// RawAxiosHeaders whose duplicates are ignored by node
|
1398
|
-
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
1399
|
-
var ignoreDuplicateOf = utils.toObjectSet(['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent']);
|
1400
|
-
|
1401
|
-
/**
|
1402
|
-
* Parse headers into an object
|
1403
|
-
*
|
1404
|
-
* ```
|
1405
|
-
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
1406
|
-
* Content-Type: application/json
|
1407
|
-
* Connection: keep-alive
|
1408
|
-
* Transfer-Encoding: chunked
|
1409
|
-
* ```
|
1410
|
-
*
|
1411
|
-
* @param {String} rawHeaders Headers needing to be parsed
|
1492
|
+
* @param {String} rawHeaders Headers needing to be parsed
|
1412
1493
|
*
|
1413
1494
|
* @returns {Object} Headers parsed into an object
|
1414
1495
|
*/
|
@@ -1438,7 +1519,6 @@
|
|
1438
1519
|
});
|
1439
1520
|
|
1440
1521
|
var $internals = Symbol('internals');
|
1441
|
-
var $defaults = Symbol('defaults');
|
1442
1522
|
function normalizeHeader(header) {
|
1443
1523
|
return header && String(header).trim().toLowerCase();
|
1444
1524
|
}
|
@@ -1457,10 +1537,16 @@
|
|
1457
1537
|
}
|
1458
1538
|
return tokens;
|
1459
1539
|
}
|
1460
|
-
function
|
1540
|
+
function isValidHeaderName(str) {
|
1541
|
+
return /^[-_a-zA-Z]+$/.test(str.trim());
|
1542
|
+
}
|
1543
|
+
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
1461
1544
|
if (utils.isFunction(filter)) {
|
1462
1545
|
return filter.call(this, value, header);
|
1463
1546
|
}
|
1547
|
+
if (isHeaderNameFilter) {
|
1548
|
+
value = header;
|
1549
|
+
}
|
1464
1550
|
if (!utils.isString(value)) return;
|
1465
1551
|
if (utils.isString(filter)) {
|
1466
1552
|
return value.indexOf(filter) !== -1;
|
@@ -1485,153 +1571,415 @@
|
|
1485
1571
|
});
|
1486
1572
|
});
|
1487
1573
|
}
|
1488
|
-
function
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
var _key;
|
1493
|
-
while (i-- > 0) {
|
1494
|
-
_key = keys[i];
|
1495
|
-
if (key === _key.toLowerCase()) {
|
1496
|
-
return _key;
|
1497
|
-
}
|
1574
|
+
var AxiosHeaders = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
|
1575
|
+
function AxiosHeaders(headers) {
|
1576
|
+
_classCallCheck(this, AxiosHeaders);
|
1577
|
+
headers && this.set(headers);
|
1498
1578
|
}
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1579
|
+
_createClass(AxiosHeaders, [{
|
1580
|
+
key: "set",
|
1581
|
+
value: function set(header, valueOrRewrite, rewrite) {
|
1582
|
+
var self = this;
|
1583
|
+
function setHeader(_value, _header, _rewrite) {
|
1584
|
+
var lHeader = normalizeHeader(_header);
|
1585
|
+
if (!lHeader) {
|
1586
|
+
throw new Error('header name must be a non-empty string');
|
1587
|
+
}
|
1588
|
+
var key = utils.findKey(self, lHeader);
|
1589
|
+
if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
|
1590
|
+
self[key || _header] = normalizeValue(_value);
|
1591
|
+
}
|
1512
1592
|
}
|
1513
|
-
var
|
1514
|
-
|
1515
|
-
|
1593
|
+
var setHeaders = function setHeaders(headers, _rewrite) {
|
1594
|
+
return utils.forEach(headers, function (_value, _header) {
|
1595
|
+
return setHeader(_value, _header, _rewrite);
|
1596
|
+
});
|
1597
|
+
};
|
1598
|
+
if (utils.isPlainObject(header) || header instanceof this.constructor) {
|
1599
|
+
setHeaders(header, valueOrRewrite);
|
1600
|
+
} else if (utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
1601
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
1602
|
+
} else {
|
1603
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
1516
1604
|
}
|
1517
|
-
|
1605
|
+
return this;
|
1518
1606
|
}
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1607
|
+
}, {
|
1608
|
+
key: "get",
|
1609
|
+
value: function get(header, parser) {
|
1610
|
+
header = normalizeHeader(header);
|
1611
|
+
if (header) {
|
1612
|
+
var key = utils.findKey(this, header);
|
1613
|
+
if (key) {
|
1614
|
+
var value = this[key];
|
1615
|
+
if (!parser) {
|
1616
|
+
return value;
|
1617
|
+
}
|
1618
|
+
if (parser === true) {
|
1619
|
+
return parseTokens(value);
|
1620
|
+
}
|
1621
|
+
if (utils.isFunction(parser)) {
|
1622
|
+
return parser.call(this, value, key);
|
1623
|
+
}
|
1624
|
+
if (utils.isRegExp(parser)) {
|
1625
|
+
return parser.exec(value);
|
1626
|
+
}
|
1627
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
1628
|
+
}
|
1536
1629
|
}
|
1537
|
-
|
1538
|
-
|
1630
|
+
}
|
1631
|
+
}, {
|
1632
|
+
key: "has",
|
1633
|
+
value: function has(header, matcher) {
|
1634
|
+
header = normalizeHeader(header);
|
1635
|
+
if (header) {
|
1636
|
+
var key = utils.findKey(this, header);
|
1637
|
+
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1539
1638
|
}
|
1540
|
-
|
1541
|
-
|
1639
|
+
return false;
|
1640
|
+
}
|
1641
|
+
}, {
|
1642
|
+
key: "delete",
|
1643
|
+
value: function _delete(header, matcher) {
|
1644
|
+
var self = this;
|
1645
|
+
var deleted = false;
|
1646
|
+
function deleteHeader(_header) {
|
1647
|
+
_header = normalizeHeader(_header);
|
1648
|
+
if (_header) {
|
1649
|
+
var key = utils.findKey(self, _header);
|
1650
|
+
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
1651
|
+
delete self[key];
|
1652
|
+
deleted = true;
|
1653
|
+
}
|
1654
|
+
}
|
1542
1655
|
}
|
1543
|
-
if (utils.
|
1544
|
-
|
1656
|
+
if (utils.isArray(header)) {
|
1657
|
+
header.forEach(deleteHeader);
|
1658
|
+
} else {
|
1659
|
+
deleteHeader(header);
|
1545
1660
|
}
|
1546
|
-
|
1547
|
-
}
|
1548
|
-
},
|
1549
|
-
has: function has(header, matcher) {
|
1550
|
-
header = normalizeHeader(header);
|
1551
|
-
if (header) {
|
1552
|
-
var key = findKey(this, header);
|
1553
|
-
return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1661
|
+
return deleted;
|
1554
1662
|
}
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
delete self[key];
|
1663
|
+
}, {
|
1664
|
+
key: "clear",
|
1665
|
+
value: function clear(matcher) {
|
1666
|
+
var keys = Object.keys(this);
|
1667
|
+
var i = keys.length;
|
1668
|
+
var deleted = false;
|
1669
|
+
while (i--) {
|
1670
|
+
var key = keys[i];
|
1671
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
1672
|
+
delete this[key];
|
1566
1673
|
deleted = true;
|
1567
1674
|
}
|
1568
1675
|
}
|
1676
|
+
return deleted;
|
1569
1677
|
}
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1678
|
+
}, {
|
1679
|
+
key: "normalize",
|
1680
|
+
value: function normalize(format) {
|
1681
|
+
var self = this;
|
1682
|
+
var headers = {};
|
1683
|
+
utils.forEach(this, function (value, header) {
|
1684
|
+
var key = utils.findKey(headers, header);
|
1685
|
+
if (key) {
|
1686
|
+
self[key] = normalizeValue(value);
|
1687
|
+
delete self[header];
|
1688
|
+
return;
|
1689
|
+
}
|
1690
|
+
var normalized = format ? formatHeader(header) : String(header).trim();
|
1691
|
+
if (normalized !== header) {
|
1692
|
+
delete self[header];
|
1693
|
+
}
|
1694
|
+
self[normalized] = normalizeValue(value);
|
1695
|
+
headers[normalized] = true;
|
1696
|
+
});
|
1697
|
+
return this;
|
1574
1698
|
}
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
var self = this;
|
1582
|
-
var headers = {};
|
1583
|
-
utils.forEach(this, function (value, header) {
|
1584
|
-
var key = findKey(headers, header);
|
1585
|
-
if (key) {
|
1586
|
-
self[key] = normalizeValue(value);
|
1587
|
-
delete self[header];
|
1588
|
-
return;
|
1699
|
+
}, {
|
1700
|
+
key: "concat",
|
1701
|
+
value: function concat() {
|
1702
|
+
var _this$constructor;
|
1703
|
+
for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
|
1704
|
+
targets[_key] = arguments[_key];
|
1589
1705
|
}
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1706
|
+
return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
|
1707
|
+
}
|
1708
|
+
}, {
|
1709
|
+
key: "toJSON",
|
1710
|
+
value: function toJSON(asStrings) {
|
1711
|
+
var obj = Object.create(null);
|
1712
|
+
utils.forEach(this, function (value, header) {
|
1713
|
+
value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
|
1714
|
+
});
|
1715
|
+
return obj;
|
1716
|
+
}
|
1717
|
+
}, {
|
1718
|
+
key: _Symbol$iterator,
|
1719
|
+
value: function value() {
|
1720
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
1721
|
+
}
|
1722
|
+
}, {
|
1723
|
+
key: "toString",
|
1724
|
+
value: function toString() {
|
1725
|
+
return Object.entries(this.toJSON()).map(function (_ref) {
|
1726
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
1727
|
+
header = _ref2[0],
|
1728
|
+
value = _ref2[1];
|
1729
|
+
return header + ': ' + value;
|
1730
|
+
}).join('\n');
|
1731
|
+
}
|
1732
|
+
}, {
|
1733
|
+
key: _Symbol$toStringTag,
|
1734
|
+
get: function get() {
|
1735
|
+
return 'AxiosHeaders';
|
1736
|
+
}
|
1737
|
+
}], [{
|
1738
|
+
key: "from",
|
1739
|
+
value: function from(thing) {
|
1740
|
+
return thing instanceof this ? thing : new this(thing);
|
1741
|
+
}
|
1742
|
+
}, {
|
1743
|
+
key: "concat",
|
1744
|
+
value: function concat(first) {
|
1745
|
+
var computed = new this(first);
|
1746
|
+
for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
1747
|
+
targets[_key2 - 1] = arguments[_key2];
|
1593
1748
|
}
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1749
|
+
targets.forEach(function (target) {
|
1750
|
+
return computed.set(target);
|
1751
|
+
});
|
1752
|
+
return computed;
|
1753
|
+
}
|
1754
|
+
}, {
|
1755
|
+
key: "accessor",
|
1756
|
+
value: function accessor(header) {
|
1757
|
+
var internals = this[$internals] = this[$internals] = {
|
1758
|
+
accessors: {}
|
1759
|
+
};
|
1760
|
+
var accessors = internals.accessors;
|
1761
|
+
var prototype = this.prototype;
|
1762
|
+
function defineAccessor(_header) {
|
1763
|
+
var lHeader = normalizeHeader(_header);
|
1764
|
+
if (!accessors[lHeader]) {
|
1765
|
+
buildAccessors(prototype, _header);
|
1766
|
+
accessors[lHeader] = true;
|
1767
|
+
}
|
1768
|
+
}
|
1769
|
+
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
1770
|
+
return this;
|
1771
|
+
}
|
1772
|
+
}]);
|
1773
|
+
return AxiosHeaders;
|
1774
|
+
}(Symbol.iterator, Symbol.toStringTag);
|
1775
|
+
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
1776
|
+
utils.freezeMethods(AxiosHeaders.prototype);
|
1777
|
+
utils.freezeMethods(AxiosHeaders);
|
1778
|
+
var AxiosHeaders$1 = AxiosHeaders;
|
1779
|
+
|
1780
|
+
/**
|
1781
|
+
* Transform the data for a request or a response
|
1782
|
+
*
|
1783
|
+
* @param {Array|Function} fns A single function or Array of functions
|
1784
|
+
* @param {?Object} response The response object
|
1785
|
+
*
|
1786
|
+
* @returns {*} The resulting transformed data
|
1787
|
+
*/
|
1788
|
+
function transformData(fns, response) {
|
1789
|
+
var config = this || defaults$1;
|
1790
|
+
var context = response || config;
|
1791
|
+
var headers = AxiosHeaders$1.from(context.headers);
|
1792
|
+
var data = context.data;
|
1793
|
+
utils.forEach(fns, function transform(fn) {
|
1794
|
+
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
1795
|
+
});
|
1796
|
+
headers.normalize();
|
1797
|
+
return data;
|
1798
|
+
}
|
1799
|
+
|
1800
|
+
function isCancel(value) {
|
1801
|
+
return !!(value && value.__CANCEL__);
|
1802
|
+
}
|
1803
|
+
|
1804
|
+
/**
|
1805
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
1806
|
+
*
|
1807
|
+
* @param {string=} message The message.
|
1808
|
+
* @param {Object=} config The config.
|
1809
|
+
* @param {Object=} request The request.
|
1810
|
+
*
|
1811
|
+
* @returns {CanceledError} The created error.
|
1812
|
+
*/
|
1813
|
+
function CanceledError(message, config, request) {
|
1814
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
1815
|
+
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
1816
|
+
this.name = 'CanceledError';
|
1817
|
+
}
|
1818
|
+
utils.inherits(CanceledError, AxiosError, {
|
1819
|
+
__CANCEL__: true
|
1820
|
+
});
|
1821
|
+
|
1822
|
+
/**
|
1823
|
+
* Resolve or reject a Promise based on response status.
|
1824
|
+
*
|
1825
|
+
* @param {Function} resolve A function that resolves the promise.
|
1826
|
+
* @param {Function} reject A function that rejects the promise.
|
1827
|
+
* @param {object} response The response.
|
1828
|
+
*
|
1829
|
+
* @returns {object} The response.
|
1830
|
+
*/
|
1831
|
+
function settle(resolve, reject, response) {
|
1832
|
+
var validateStatus = response.config.validateStatus;
|
1833
|
+
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
1834
|
+
resolve(response);
|
1835
|
+
} else {
|
1836
|
+
reject(new AxiosError('Request failed with status code ' + response.status, [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
|
1837
|
+
}
|
1838
|
+
}
|
1839
|
+
|
1840
|
+
var cookies = platform.isStandardBrowserEnv ?
|
1841
|
+
// Standard browser envs support document.cookie
|
1842
|
+
function standardBrowserEnv() {
|
1843
|
+
return {
|
1844
|
+
write: function write(name, value, expires, path, domain, secure) {
|
1845
|
+
var cookie = [];
|
1846
|
+
cookie.push(name + '=' + encodeURIComponent(value));
|
1847
|
+
if (utils.isNumber(expires)) {
|
1848
|
+
cookie.push('expires=' + new Date(expires).toGMTString());
|
1849
|
+
}
|
1850
|
+
if (utils.isString(path)) {
|
1851
|
+
cookie.push('path=' + path);
|
1852
|
+
}
|
1853
|
+
if (utils.isString(domain)) {
|
1854
|
+
cookie.push('domain=' + domain);
|
1855
|
+
}
|
1856
|
+
if (secure === true) {
|
1857
|
+
cookie.push('secure');
|
1858
|
+
}
|
1859
|
+
document.cookie = cookie.join('; ');
|
1860
|
+
},
|
1861
|
+
read: function read(name) {
|
1862
|
+
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
1863
|
+
return match ? decodeURIComponent(match[3]) : null;
|
1864
|
+
},
|
1865
|
+
remove: function remove(name) {
|
1866
|
+
this.write(name, '', Date.now() - 86400000);
|
1867
|
+
}
|
1868
|
+
};
|
1869
|
+
}() :
|
1870
|
+
// Non standard browser env (web workers, react-native) lack needed support.
|
1871
|
+
function nonStandardBrowserEnv() {
|
1872
|
+
return {
|
1873
|
+
write: function write() {},
|
1874
|
+
read: function read() {
|
1875
|
+
return null;
|
1876
|
+
},
|
1877
|
+
remove: function remove() {}
|
1878
|
+
};
|
1879
|
+
}();
|
1880
|
+
|
1881
|
+
/**
|
1882
|
+
* Determines whether the specified URL is absolute
|
1883
|
+
*
|
1884
|
+
* @param {string} url The URL to test
|
1885
|
+
*
|
1886
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
1887
|
+
*/
|
1888
|
+
function isAbsoluteURL(url) {
|
1889
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
1890
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
1891
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
1892
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
1893
|
+
}
|
1894
|
+
|
1895
|
+
/**
|
1896
|
+
* Creates a new URL by combining the specified URLs
|
1897
|
+
*
|
1898
|
+
* @param {string} baseURL The base URL
|
1899
|
+
* @param {string} relativeURL The relative URL
|
1900
|
+
*
|
1901
|
+
* @returns {string} The combined URL
|
1902
|
+
*/
|
1903
|
+
function combineURLs(baseURL, relativeURL) {
|
1904
|
+
return relativeURL ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
|
1905
|
+
}
|
1906
|
+
|
1907
|
+
/**
|
1908
|
+
* Creates a new URL by combining the baseURL with the requestedURL,
|
1909
|
+
* only when the requestedURL is not already an absolute URL.
|
1910
|
+
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
1911
|
+
*
|
1912
|
+
* @param {string} baseURL The base URL
|
1913
|
+
* @param {string} requestedURL Absolute or relative URL to combine
|
1914
|
+
*
|
1915
|
+
* @returns {string} The combined full path
|
1916
|
+
*/
|
1917
|
+
function buildFullPath(baseURL, requestedURL) {
|
1918
|
+
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
1919
|
+
return combineURLs(baseURL, requestedURL);
|
1606
1920
|
}
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1921
|
+
return requestedURL;
|
1922
|
+
}
|
1923
|
+
|
1924
|
+
var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
1925
|
+
// Standard browser envs have full support of the APIs needed to test
|
1926
|
+
// whether the request URL is of the same origin as current location.
|
1927
|
+
function standardBrowserEnv() {
|
1928
|
+
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
1929
|
+
var urlParsingNode = document.createElement('a');
|
1930
|
+
var originURL;
|
1931
|
+
|
1932
|
+
/**
|
1933
|
+
* Parse a URL to discover it's components
|
1934
|
+
*
|
1935
|
+
* @param {String} url The URL to be parsed
|
1936
|
+
* @returns {Object}
|
1937
|
+
*/
|
1938
|
+
function resolveURL(url) {
|
1939
|
+
var href = url;
|
1940
|
+
if (msie) {
|
1941
|
+
// IE needs attribute set twice to normalize properties
|
1942
|
+
urlParsingNode.setAttribute('href', href);
|
1943
|
+
href = urlParsingNode.href;
|
1612
1944
|
}
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1945
|
+
urlParsingNode.setAttribute('href', href);
|
1946
|
+
|
1947
|
+
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
1948
|
+
return {
|
1949
|
+
href: urlParsingNode.href,
|
1950
|
+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
1951
|
+
host: urlParsingNode.host,
|
1952
|
+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
1953
|
+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
1954
|
+
hostname: urlParsingNode.hostname,
|
1955
|
+
port: urlParsingNode.port,
|
1956
|
+
pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname
|
1618
1957
|
};
|
1619
|
-
var accessors = internals.accessors;
|
1620
|
-
var prototype = this.prototype;
|
1621
|
-
function defineAccessor(_header) {
|
1622
|
-
var lHeader = normalizeHeader(_header);
|
1623
|
-
if (!accessors[lHeader]) {
|
1624
|
-
buildAccessors(prototype, _header);
|
1625
|
-
accessors[lHeader] = true;
|
1626
|
-
}
|
1627
|
-
}
|
1628
|
-
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
1629
|
-
return this;
|
1630
1958
|
}
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1959
|
+
originURL = resolveURL(window.location.href);
|
1960
|
+
|
1961
|
+
/**
|
1962
|
+
* Determine if a URL shares the same origin as the current location
|
1963
|
+
*
|
1964
|
+
* @param {String} requestURL The URL to test
|
1965
|
+
* @returns {boolean} True if URL shares the same origin, otherwise false
|
1966
|
+
*/
|
1967
|
+
return function isURLSameOrigin(requestURL) {
|
1968
|
+
var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
1969
|
+
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
1970
|
+
};
|
1971
|
+
}() :
|
1972
|
+
// Non standard browser envs (web workers, react-native) lack needed support.
|
1973
|
+
function nonStandardBrowserEnv() {
|
1974
|
+
return function isURLSameOrigin() {
|
1975
|
+
return true;
|
1976
|
+
};
|
1977
|
+
}();
|
1978
|
+
|
1979
|
+
function parseProtocol(url) {
|
1980
|
+
var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
1981
|
+
return match && match[1] || '';
|
1982
|
+
}
|
1635
1983
|
|
1636
1984
|
/**
|
1637
1985
|
* Calculate data maxRate
|
@@ -1689,16 +2037,18 @@
|
|
1689
2037
|
progress: total ? loaded / total : undefined,
|
1690
2038
|
bytes: progressBytes,
|
1691
2039
|
rate: rate ? rate : undefined,
|
1692
|
-
estimated: rate && total && inRange ? (total - loaded) / rate : undefined
|
2040
|
+
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
2041
|
+
event: e
|
1693
2042
|
};
|
1694
2043
|
data[isDownloadStream ? 'download' : 'upload'] = true;
|
1695
2044
|
listener(data);
|
1696
2045
|
};
|
1697
2046
|
}
|
1698
|
-
|
2047
|
+
var isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
2048
|
+
var xhrAdapter = isXHRAdapterSupported && function (config) {
|
1699
2049
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
1700
2050
|
var requestData = config.data;
|
1701
|
-
var requestHeaders = AxiosHeaders.from(config.headers).normalize();
|
2051
|
+
var requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
|
1702
2052
|
var responseType = config.responseType;
|
1703
2053
|
var onCanceled;
|
1704
2054
|
function done() {
|
@@ -1709,7 +2059,7 @@
|
|
1709
2059
|
config.signal.removeEventListener('abort', onCanceled);
|
1710
2060
|
}
|
1711
2061
|
}
|
1712
|
-
if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
|
2062
|
+
if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
|
1713
2063
|
requestHeaders.setContentType(false); // Let the browser set it
|
1714
2064
|
}
|
1715
2065
|
|
@@ -1731,7 +2081,7 @@
|
|
1731
2081
|
return;
|
1732
2082
|
}
|
1733
2083
|
// Prepare the response
|
1734
|
-
var responseHeaders = AxiosHeaders.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
|
2084
|
+
var responseHeaders = AxiosHeaders$1.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
|
1735
2085
|
var responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
|
1736
2086
|
var response = {
|
1737
2087
|
data: responseData,
|
@@ -1874,191 +2224,52 @@
|
|
1874
2224
|
// Send the request
|
1875
2225
|
request.send(requestData || null);
|
1876
2226
|
});
|
1877
|
-
}
|
1878
|
-
|
1879
|
-
var adapters = {
|
1880
|
-
http: xhrAdapter,
|
1881
|
-
xhr: xhrAdapter
|
1882
|
-
};
|
1883
|
-
var adapters$1 = {
|
1884
|
-
getAdapter: function getAdapter(nameOrAdapter) {
|
1885
|
-
if (utils.isString(nameOrAdapter)) {
|
1886
|
-
var adapter = adapters[nameOrAdapter];
|
1887
|
-
if (!nameOrAdapter) {
|
1888
|
-
throw Error(utils.hasOwnProp(nameOrAdapter) ? "Adapter '".concat(nameOrAdapter, "' is not available in the build") : "Can not resolve adapter '".concat(nameOrAdapter, "'"));
|
1889
|
-
}
|
1890
|
-
return adapter;
|
1891
|
-
}
|
1892
|
-
if (!utils.isFunction(nameOrAdapter)) {
|
1893
|
-
throw new TypeError('adapter is not a function');
|
1894
|
-
}
|
1895
|
-
return nameOrAdapter;
|
1896
|
-
},
|
1897
|
-
adapters: adapters
|
1898
2227
|
};
|
1899
2228
|
|
1900
|
-
var
|
1901
|
-
|
2229
|
+
var knownAdapters = {
|
2230
|
+
http: httpAdapter,
|
2231
|
+
xhr: xhrAdapter
|
1902
2232
|
};
|
1903
|
-
|
1904
|
-
|
1905
|
-
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
|
1906
|
-
* adapter
|
1907
|
-
*
|
1908
|
-
* @returns {Function}
|
1909
|
-
*/
|
1910
|
-
function getDefaultAdapter() {
|
1911
|
-
var adapter;
|
1912
|
-
if (typeof XMLHttpRequest !== 'undefined') {
|
1913
|
-
// For browsers use XHR adapter
|
1914
|
-
adapter = adapters$1.getAdapter('xhr');
|
1915
|
-
} else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
|
1916
|
-
// For node use HTTP adapter
|
1917
|
-
adapter = adapters$1.getAdapter('http');
|
1918
|
-
}
|
1919
|
-
return adapter;
|
1920
|
-
}
|
1921
|
-
|
1922
|
-
/**
|
1923
|
-
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
1924
|
-
* of the input
|
1925
|
-
*
|
1926
|
-
* @param {any} rawValue - The value to be stringified.
|
1927
|
-
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
1928
|
-
* @param {Function} encoder - A function that takes a value and returns a string.
|
1929
|
-
*
|
1930
|
-
* @returns {string} A stringified version of the rawValue.
|
1931
|
-
*/
|
1932
|
-
function stringifySafely(rawValue, parser, encoder) {
|
1933
|
-
if (utils.isString(rawValue)) {
|
2233
|
+
utils.forEach(knownAdapters, function (fn, value) {
|
2234
|
+
if (fn) {
|
1934
2235
|
try {
|
1935
|
-
(
|
1936
|
-
|
2236
|
+
Object.defineProperty(fn, 'name', {
|
2237
|
+
value: value
|
2238
|
+
});
|
1937
2239
|
} catch (e) {
|
1938
|
-
|
1939
|
-
throw e;
|
1940
|
-
}
|
2240
|
+
// eslint-disable-next-line no-empty
|
1941
2241
|
}
|
2242
|
+
Object.defineProperty(fn, 'adapterName', {
|
2243
|
+
value: value
|
2244
|
+
});
|
1942
2245
|
}
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
var
|
1950
|
-
var
|
1951
|
-
var
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
var isFormData = utils.isFormData(data);
|
1956
|
-
if (isFormData) {
|
1957
|
-
if (!hasJSONContentType) {
|
1958
|
-
return data;
|
2246
|
+
});
|
2247
|
+
var adapters = {
|
2248
|
+
getAdapter: function getAdapter(adapters) {
|
2249
|
+
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
2250
|
+
var _adapters = adapters,
|
2251
|
+
length = _adapters.length;
|
2252
|
+
var nameOrAdapter;
|
2253
|
+
var adapter;
|
2254
|
+
for (var i = 0; i < length; i++) {
|
2255
|
+
nameOrAdapter = adapters[i];
|
2256
|
+
if (adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter) {
|
2257
|
+
break;
|
1959
2258
|
}
|
1960
|
-
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
1961
|
-
}
|
1962
|
-
if (utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data)) {
|
1963
|
-
return data;
|
1964
|
-
}
|
1965
|
-
if (utils.isArrayBufferView(data)) {
|
1966
|
-
return data.buffer;
|
1967
2259
|
}
|
1968
|
-
if (
|
1969
|
-
|
1970
|
-
|
1971
|
-
}
|
1972
|
-
var isFileList;
|
1973
|
-
if (isObjectPayload) {
|
1974
|
-
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
1975
|
-
return toURLEncodedForm(data, this.formSerializer).toString();
|
2260
|
+
if (!adapter) {
|
2261
|
+
if (adapter === false) {
|
2262
|
+
throw new AxiosError("Adapter ".concat(nameOrAdapter, " is not supported by the environment"), 'ERR_NOT_SUPPORT');
|
1976
2263
|
}
|
1977
|
-
|
1978
|
-
var _FormData = this.env && this.env.FormData;
|
1979
|
-
return toFormData(isFileList ? {
|
1980
|
-
'files[]': data
|
1981
|
-
} : data, _FormData && new _FormData(), this.formSerializer);
|
1982
|
-
}
|
1983
|
-
}
|
1984
|
-
if (isObjectPayload || hasJSONContentType) {
|
1985
|
-
headers.setContentType('application/json', false);
|
1986
|
-
return stringifySafely(data);
|
2264
|
+
throw new Error(utils.hasOwnProp(knownAdapters, nameOrAdapter) ? "Adapter '".concat(nameOrAdapter, "' is not available in the build") : "Unknown adapter '".concat(nameOrAdapter, "'"));
|
1987
2265
|
}
|
1988
|
-
|
1989
|
-
|
1990
|
-
transformResponse: [function transformResponse(data) {
|
1991
|
-
var transitional = this.transitional || defaults.transitional;
|
1992
|
-
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
1993
|
-
var JSONRequested = this.responseType === 'json';
|
1994
|
-
if (data && utils.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
1995
|
-
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
1996
|
-
var strictJSONParsing = !silentJSONParsing && JSONRequested;
|
1997
|
-
try {
|
1998
|
-
return JSON.parse(data);
|
1999
|
-
} catch (e) {
|
2000
|
-
if (strictJSONParsing) {
|
2001
|
-
if (e.name === 'SyntaxError') {
|
2002
|
-
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
2003
|
-
}
|
2004
|
-
throw e;
|
2005
|
-
}
|
2006
|
-
}
|
2266
|
+
if (!utils.isFunction(adapter)) {
|
2267
|
+
throw new TypeError('adapter is not a function');
|
2007
2268
|
}
|
2008
|
-
return
|
2009
|
-
}],
|
2010
|
-
/**
|
2011
|
-
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
2012
|
-
* timeout is not created.
|
2013
|
-
*/
|
2014
|
-
timeout: 0,
|
2015
|
-
xsrfCookieName: 'XSRF-TOKEN',
|
2016
|
-
xsrfHeaderName: 'X-XSRF-TOKEN',
|
2017
|
-
maxContentLength: -1,
|
2018
|
-
maxBodyLength: -1,
|
2019
|
-
env: {
|
2020
|
-
FormData: platform.classes.FormData,
|
2021
|
-
Blob: platform.classes.Blob
|
2269
|
+
return adapter;
|
2022
2270
|
},
|
2023
|
-
|
2024
|
-
return status >= 200 && status < 300;
|
2025
|
-
},
|
2026
|
-
headers: {
|
2027
|
-
common: {
|
2028
|
-
'Accept': 'application/json, text/plain, */*'
|
2029
|
-
}
|
2030
|
-
}
|
2271
|
+
adapters: knownAdapters
|
2031
2272
|
};
|
2032
|
-
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
2033
|
-
defaults.headers[method] = {};
|
2034
|
-
});
|
2035
|
-
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
2036
|
-
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
2037
|
-
});
|
2038
|
-
|
2039
|
-
/**
|
2040
|
-
* Transform the data for a request or a response
|
2041
|
-
*
|
2042
|
-
* @param {Array|Function} fns A single function or Array of functions
|
2043
|
-
* @param {?Object} response The response object
|
2044
|
-
*
|
2045
|
-
* @returns {*} The resulting transformed data
|
2046
|
-
*/
|
2047
|
-
function transformData(fns, response) {
|
2048
|
-
var config = this || defaults;
|
2049
|
-
var context = response || config;
|
2050
|
-
var headers = AxiosHeaders.from(context.headers);
|
2051
|
-
var data = context.data;
|
2052
|
-
utils.forEach(fns, function transform(fn) {
|
2053
|
-
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
2054
|
-
});
|
2055
|
-
headers.normalize();
|
2056
|
-
return data;
|
2057
|
-
}
|
2058
|
-
|
2059
|
-
function isCancel(value) {
|
2060
|
-
return !!(value && value.__CANCEL__);
|
2061
|
-
}
|
2062
2273
|
|
2063
2274
|
/**
|
2064
2275
|
* Throws a `CanceledError` if cancellation has been requested.
|
@@ -2072,7 +2283,7 @@
|
|
2072
2283
|
config.cancelToken.throwIfRequested();
|
2073
2284
|
}
|
2074
2285
|
if (config.signal && config.signal.aborted) {
|
2075
|
-
throw new CanceledError();
|
2286
|
+
throw new CanceledError(null, config);
|
2076
2287
|
}
|
2077
2288
|
}
|
2078
2289
|
|
@@ -2085,17 +2296,20 @@
|
|
2085
2296
|
*/
|
2086
2297
|
function dispatchRequest(config) {
|
2087
2298
|
throwIfCancellationRequested(config);
|
2088
|
-
config.headers = AxiosHeaders.from(config.headers);
|
2299
|
+
config.headers = AxiosHeaders$1.from(config.headers);
|
2089
2300
|
|
2090
2301
|
// Transform request data
|
2091
2302
|
config.data = transformData.call(config, config.transformRequest);
|
2092
|
-
|
2303
|
+
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
2304
|
+
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
2305
|
+
}
|
2306
|
+
var adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
2093
2307
|
return adapter(config).then(function onAdapterResolution(response) {
|
2094
2308
|
throwIfCancellationRequested(config);
|
2095
2309
|
|
2096
2310
|
// Transform response data
|
2097
2311
|
response.data = transformData.call(config, config.transformResponse, response);
|
2098
|
-
response.headers = AxiosHeaders.from(response.headers);
|
2312
|
+
response.headers = AxiosHeaders$1.from(response.headers);
|
2099
2313
|
return response;
|
2100
2314
|
}, function onAdapterRejection(reason) {
|
2101
2315
|
if (!isCancel(reason)) {
|
@@ -2104,13 +2318,17 @@
|
|
2104
2318
|
// Transform response data
|
2105
2319
|
if (reason && reason.response) {
|
2106
2320
|
reason.response.data = transformData.call(config, config.transformResponse, reason.response);
|
2107
|
-
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
2321
|
+
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
2108
2322
|
}
|
2109
2323
|
}
|
2110
2324
|
return Promise.reject(reason);
|
2111
2325
|
});
|
2112
2326
|
}
|
2113
2327
|
|
2328
|
+
var headersToObject = function headersToObject(thing) {
|
2329
|
+
return thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
|
2330
|
+
};
|
2331
|
+
|
2114
2332
|
/**
|
2115
2333
|
* Config-specific merge-function which creates a new config-object
|
2116
2334
|
* by merging two configuration objects together.
|
@@ -2124,9 +2342,11 @@
|
|
2124
2342
|
// eslint-disable-next-line no-param-reassign
|
2125
2343
|
config2 = config2 || {};
|
2126
2344
|
var config = {};
|
2127
|
-
function getMergedValue(target, source) {
|
2345
|
+
function getMergedValue(target, source, caseless) {
|
2128
2346
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
2129
|
-
return utils.merge(
|
2347
|
+
return utils.merge.call({
|
2348
|
+
caseless: caseless
|
2349
|
+
}, target, source);
|
2130
2350
|
} else if (utils.isPlainObject(source)) {
|
2131
2351
|
return utils.merge({}, source);
|
2132
2352
|
} else if (utils.isArray(source)) {
|
@@ -2136,76 +2356,79 @@
|
|
2136
2356
|
}
|
2137
2357
|
|
2138
2358
|
// eslint-disable-next-line consistent-return
|
2139
|
-
function mergeDeepProperties(
|
2140
|
-
if (!utils.isUndefined(
|
2141
|
-
return getMergedValue(
|
2142
|
-
} else if (!utils.isUndefined(
|
2143
|
-
return getMergedValue(undefined,
|
2359
|
+
function mergeDeepProperties(a, b, caseless) {
|
2360
|
+
if (!utils.isUndefined(b)) {
|
2361
|
+
return getMergedValue(a, b, caseless);
|
2362
|
+
} else if (!utils.isUndefined(a)) {
|
2363
|
+
return getMergedValue(undefined, a, caseless);
|
2144
2364
|
}
|
2145
2365
|
}
|
2146
2366
|
|
2147
2367
|
// eslint-disable-next-line consistent-return
|
2148
|
-
function valueFromConfig2(
|
2149
|
-
if (!utils.isUndefined(
|
2150
|
-
return getMergedValue(undefined,
|
2368
|
+
function valueFromConfig2(a, b) {
|
2369
|
+
if (!utils.isUndefined(b)) {
|
2370
|
+
return getMergedValue(undefined, b);
|
2151
2371
|
}
|
2152
2372
|
}
|
2153
2373
|
|
2154
2374
|
// eslint-disable-next-line consistent-return
|
2155
|
-
function defaultToConfig2(
|
2156
|
-
if (!utils.isUndefined(
|
2157
|
-
return getMergedValue(undefined,
|
2158
|
-
} else if (!utils.isUndefined(
|
2159
|
-
return getMergedValue(undefined,
|
2375
|
+
function defaultToConfig2(a, b) {
|
2376
|
+
if (!utils.isUndefined(b)) {
|
2377
|
+
return getMergedValue(undefined, b);
|
2378
|
+
} else if (!utils.isUndefined(a)) {
|
2379
|
+
return getMergedValue(undefined, a);
|
2160
2380
|
}
|
2161
2381
|
}
|
2162
2382
|
|
2163
2383
|
// eslint-disable-next-line consistent-return
|
2164
|
-
function mergeDirectKeys(prop) {
|
2384
|
+
function mergeDirectKeys(a, b, prop) {
|
2165
2385
|
if (prop in config2) {
|
2166
|
-
return getMergedValue(
|
2386
|
+
return getMergedValue(a, b);
|
2167
2387
|
} else if (prop in config1) {
|
2168
|
-
return getMergedValue(undefined,
|
2388
|
+
return getMergedValue(undefined, a);
|
2169
2389
|
}
|
2170
2390
|
}
|
2171
2391
|
var mergeMap = {
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2392
|
+
url: valueFromConfig2,
|
2393
|
+
method: valueFromConfig2,
|
2394
|
+
data: valueFromConfig2,
|
2395
|
+
baseURL: defaultToConfig2,
|
2396
|
+
transformRequest: defaultToConfig2,
|
2397
|
+
transformResponse: defaultToConfig2,
|
2398
|
+
paramsSerializer: defaultToConfig2,
|
2399
|
+
timeout: defaultToConfig2,
|
2400
|
+
timeoutMessage: defaultToConfig2,
|
2401
|
+
withCredentials: defaultToConfig2,
|
2402
|
+
adapter: defaultToConfig2,
|
2403
|
+
responseType: defaultToConfig2,
|
2404
|
+
xsrfCookieName: defaultToConfig2,
|
2405
|
+
xsrfHeaderName: defaultToConfig2,
|
2406
|
+
onUploadProgress: defaultToConfig2,
|
2407
|
+
onDownloadProgress: defaultToConfig2,
|
2408
|
+
decompress: defaultToConfig2,
|
2409
|
+
maxContentLength: defaultToConfig2,
|
2410
|
+
maxBodyLength: defaultToConfig2,
|
2411
|
+
beforeRedirect: defaultToConfig2,
|
2412
|
+
transport: defaultToConfig2,
|
2413
|
+
httpAgent: defaultToConfig2,
|
2414
|
+
httpsAgent: defaultToConfig2,
|
2415
|
+
cancelToken: defaultToConfig2,
|
2416
|
+
socketPath: defaultToConfig2,
|
2417
|
+
responseEncoding: defaultToConfig2,
|
2418
|
+
validateStatus: mergeDirectKeys,
|
2419
|
+
headers: function headers(a, b) {
|
2420
|
+
return mergeDeepProperties(headersToObject(a), headersToObject(b), true);
|
2421
|
+
}
|
2199
2422
|
};
|
2200
2423
|
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
2201
2424
|
var merge = mergeMap[prop] || mergeDeepProperties;
|
2202
|
-
var configValue = merge(prop);
|
2425
|
+
var configValue = merge(config1[prop], config2[prop], prop);
|
2203
2426
|
utils.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
|
2204
2427
|
});
|
2205
2428
|
return config;
|
2206
2429
|
}
|
2207
2430
|
|
2208
|
-
var VERSION = "1.
|
2431
|
+
var VERSION = "1.3.4";
|
2209
2432
|
|
2210
2433
|
var validators$1 = {};
|
2211
2434
|
|
@@ -2296,8 +2519,8 @@
|
|
2296
2519
|
_classCallCheck(this, Axios);
|
2297
2520
|
this.defaults = instanceConfig;
|
2298
2521
|
this.interceptors = {
|
2299
|
-
request: new InterceptorManager(),
|
2300
|
-
response: new InterceptorManager()
|
2522
|
+
request: new InterceptorManager$1(),
|
2523
|
+
response: new InterceptorManager$1()
|
2301
2524
|
};
|
2302
2525
|
}
|
2303
2526
|
|
@@ -2323,7 +2546,8 @@
|
|
2323
2546
|
config = mergeConfig(this.defaults, config);
|
2324
2547
|
var _config = config,
|
2325
2548
|
transitional = _config.transitional,
|
2326
|
-
paramsSerializer = _config.paramsSerializer
|
2549
|
+
paramsSerializer = _config.paramsSerializer,
|
2550
|
+
headers = _config.headers;
|
2327
2551
|
if (transitional !== undefined) {
|
2328
2552
|
validator.assertOptions(transitional, {
|
2329
2553
|
silentJSONParsing: validators.transitional(validators["boolean"]),
|
@@ -2340,13 +2564,14 @@
|
|
2340
2564
|
|
2341
2565
|
// Set config.method
|
2342
2566
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
2567
|
+
var contextHeaders;
|
2343
2568
|
|
2344
2569
|
// Flatten headers
|
2345
|
-
|
2346
|
-
|
2347
|
-
delete
|
2570
|
+
contextHeaders = headers && utils.merge(headers.common, headers[config.method]);
|
2571
|
+
contextHeaders && utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function (method) {
|
2572
|
+
delete headers[method];
|
2348
2573
|
});
|
2349
|
-
config.headers =
|
2574
|
+
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
2350
2575
|
|
2351
2576
|
// filter out skipped interceptors
|
2352
2577
|
var requestInterceptorChain = [];
|
@@ -2439,6 +2664,7 @@
|
|
2439
2664
|
Axios.prototype[method] = generateHTTPMethod();
|
2440
2665
|
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
2441
2666
|
});
|
2667
|
+
var Axios$1 = Axios;
|
2442
2668
|
|
2443
2669
|
/**
|
2444
2670
|
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
@@ -2554,6 +2780,7 @@
|
|
2554
2780
|
}]);
|
2555
2781
|
return CancelToken;
|
2556
2782
|
}();
|
2783
|
+
var CancelToken$1 = CancelToken;
|
2557
2784
|
|
2558
2785
|
/**
|
2559
2786
|
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
@@ -2593,6 +2820,79 @@
|
|
2593
2820
|
return utils.isObject(payload) && payload.isAxiosError === true;
|
2594
2821
|
}
|
2595
2822
|
|
2823
|
+
var HttpStatusCode = {
|
2824
|
+
Continue: 100,
|
2825
|
+
SwitchingProtocols: 101,
|
2826
|
+
Processing: 102,
|
2827
|
+
EarlyHints: 103,
|
2828
|
+
Ok: 200,
|
2829
|
+
Created: 201,
|
2830
|
+
Accepted: 202,
|
2831
|
+
NonAuthoritativeInformation: 203,
|
2832
|
+
NoContent: 204,
|
2833
|
+
ResetContent: 205,
|
2834
|
+
PartialContent: 206,
|
2835
|
+
MultiStatus: 207,
|
2836
|
+
AlreadyReported: 208,
|
2837
|
+
ImUsed: 226,
|
2838
|
+
MultipleChoices: 300,
|
2839
|
+
MovedPermanently: 301,
|
2840
|
+
Found: 302,
|
2841
|
+
SeeOther: 303,
|
2842
|
+
NotModified: 304,
|
2843
|
+
UseProxy: 305,
|
2844
|
+
Unused: 306,
|
2845
|
+
TemporaryRedirect: 307,
|
2846
|
+
PermanentRedirect: 308,
|
2847
|
+
BadRequest: 400,
|
2848
|
+
Unauthorized: 401,
|
2849
|
+
PaymentRequired: 402,
|
2850
|
+
Forbidden: 403,
|
2851
|
+
NotFound: 404,
|
2852
|
+
MethodNotAllowed: 405,
|
2853
|
+
NotAcceptable: 406,
|
2854
|
+
ProxyAuthenticationRequired: 407,
|
2855
|
+
RequestTimeout: 408,
|
2856
|
+
Conflict: 409,
|
2857
|
+
Gone: 410,
|
2858
|
+
LengthRequired: 411,
|
2859
|
+
PreconditionFailed: 412,
|
2860
|
+
PayloadTooLarge: 413,
|
2861
|
+
UriTooLong: 414,
|
2862
|
+
UnsupportedMediaType: 415,
|
2863
|
+
RangeNotSatisfiable: 416,
|
2864
|
+
ExpectationFailed: 417,
|
2865
|
+
ImATeapot: 418,
|
2866
|
+
MisdirectedRequest: 421,
|
2867
|
+
UnprocessableEntity: 422,
|
2868
|
+
Locked: 423,
|
2869
|
+
FailedDependency: 424,
|
2870
|
+
TooEarly: 425,
|
2871
|
+
UpgradeRequired: 426,
|
2872
|
+
PreconditionRequired: 428,
|
2873
|
+
TooManyRequests: 429,
|
2874
|
+
RequestHeaderFieldsTooLarge: 431,
|
2875
|
+
UnavailableForLegalReasons: 451,
|
2876
|
+
InternalServerError: 500,
|
2877
|
+
NotImplemented: 501,
|
2878
|
+
BadGateway: 502,
|
2879
|
+
ServiceUnavailable: 503,
|
2880
|
+
GatewayTimeout: 504,
|
2881
|
+
HttpVersionNotSupported: 505,
|
2882
|
+
VariantAlsoNegotiates: 506,
|
2883
|
+
InsufficientStorage: 507,
|
2884
|
+
LoopDetected: 508,
|
2885
|
+
NotExtended: 510,
|
2886
|
+
NetworkAuthenticationRequired: 511
|
2887
|
+
};
|
2888
|
+
Object.entries(HttpStatusCode).forEach(function (_ref) {
|
2889
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
2890
|
+
key = _ref2[0],
|
2891
|
+
value = _ref2[1];
|
2892
|
+
HttpStatusCode[value] = key;
|
2893
|
+
});
|
2894
|
+
var HttpStatusCode$1 = HttpStatusCode;
|
2895
|
+
|
2596
2896
|
/**
|
2597
2897
|
* Create an instance of Axios
|
2598
2898
|
*
|
@@ -2601,11 +2901,11 @@
|
|
2601
2901
|
* @returns {Axios} A new instance of Axios
|
2602
2902
|
*/
|
2603
2903
|
function createInstance(defaultConfig) {
|
2604
|
-
var context = new Axios(defaultConfig);
|
2605
|
-
var instance = bind(Axios.prototype.request, context);
|
2904
|
+
var context = new Axios$1(defaultConfig);
|
2905
|
+
var instance = bind(Axios$1.prototype.request, context);
|
2606
2906
|
|
2607
2907
|
// Copy axios.prototype to instance
|
2608
|
-
utils.extend(instance, Axios.prototype, context, {
|
2908
|
+
utils.extend(instance, Axios$1.prototype, context, {
|
2609
2909
|
allOwnKeys: true
|
2610
2910
|
});
|
2611
2911
|
|
@@ -2622,14 +2922,14 @@
|
|
2622
2922
|
}
|
2623
2923
|
|
2624
2924
|
// Create the default instance to be exported
|
2625
|
-
var axios = createInstance(defaults);
|
2925
|
+
var axios = createInstance(defaults$1);
|
2626
2926
|
|
2627
2927
|
// Expose Axios class to allow class inheritance
|
2628
|
-
axios.Axios = Axios;
|
2928
|
+
axios.Axios = Axios$1;
|
2629
2929
|
|
2630
2930
|
// Expose Cancel & CancelToken
|
2631
2931
|
axios.CanceledError = CanceledError;
|
2632
|
-
axios.CancelToken = CancelToken;
|
2932
|
+
axios.CancelToken = CancelToken$1;
|
2633
2933
|
axios.isCancel = isCancel;
|
2634
2934
|
axios.VERSION = VERSION;
|
2635
2935
|
axios.toFormData = toFormData;
|
@@ -2648,9 +2948,15 @@
|
|
2648
2948
|
|
2649
2949
|
// Expose isAxiosError
|
2650
2950
|
axios.isAxiosError = isAxiosError;
|
2951
|
+
|
2952
|
+
// Expose mergeConfig
|
2953
|
+
axios.mergeConfig = mergeConfig;
|
2954
|
+
axios.AxiosHeaders = AxiosHeaders$1;
|
2651
2955
|
axios.formToJSON = function (thing) {
|
2652
2956
|
return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
2653
2957
|
};
|
2958
|
+
axios.HttpStatusCode = HttpStatusCode$1;
|
2959
|
+
axios["default"] = axios;
|
2654
2960
|
|
2655
2961
|
return axios;
|
2656
2962
|
|