axios 1.1.3 → 1.3.3
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 +298 -75
- package/{UPGRADE_GUIDE.md → MIGRATION_GUIDE.md} +1 -1
- package/README.md +61 -25
- package/dist/axios.js +886 -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 +3189 -0
- package/dist/browser/axios.cjs.map +1 -0
- package/dist/esm/axios.js +886 -625
- 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 +972 -554
- 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 +87 -34
- 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/FormData.js +1 -1
- package/lib/platform/browser/index.js +20 -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.3 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,7 @@
|
|
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;
|
1092
1213
|
|
1093
1214
|
/**
|
1094
1215
|
* Determine if we're running in a standard browser environment
|
@@ -1114,6 +1235,21 @@
|
|
1114
1235
|
}
|
1115
1236
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
1116
1237
|
}();
|
1238
|
+
|
1239
|
+
/**
|
1240
|
+
* Determine if we're running in a standard browser webWorker environment
|
1241
|
+
*
|
1242
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
1243
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
1244
|
+
* filtered out due to its judgment standard
|
1245
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
1246
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
1247
|
+
*/
|
1248
|
+
var isStandardBrowserWebWorkerEnv = function () {
|
1249
|
+
return typeof WorkerGlobalScope !== 'undefined' &&
|
1250
|
+
// eslint-disable-next-line no-undef
|
1251
|
+
self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
|
1252
|
+
}();
|
1117
1253
|
var platform = {
|
1118
1254
|
isBrowser: true,
|
1119
1255
|
classes: {
|
@@ -1122,6 +1258,7 @@
|
|
1122
1258
|
Blob: Blob
|
1123
1259
|
},
|
1124
1260
|
isStandardBrowserEnv: isStandardBrowserEnv,
|
1261
|
+
isStandardBrowserWebWorkerEnv: isStandardBrowserWebWorkerEnv,
|
1125
1262
|
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
1126
1263
|
};
|
1127
1264
|
|
@@ -1214,203 +1351,145 @@
|
|
1214
1351
|
return null;
|
1215
1352
|
}
|
1216
1353
|
|
1354
|
+
var DEFAULT_CONTENT_TYPE = {
|
1355
|
+
'Content-Type': undefined
|
1356
|
+
};
|
1357
|
+
|
1217
1358
|
/**
|
1218
|
-
*
|
1359
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
1360
|
+
* of the input
|
1219
1361
|
*
|
1220
|
-
* @param {
|
1221
|
-
* @param {Function}
|
1222
|
-
* @param {
|
1362
|
+
* @param {any} rawValue - The value to be stringified.
|
1363
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
1364
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
1223
1365
|
*
|
1224
|
-
* @returns {
|
1366
|
+
* @returns {string} A stringified version of the rawValue.
|
1225
1367
|
*/
|
1226
|
-
function
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1368
|
+
function stringifySafely(rawValue, parser, encoder) {
|
1369
|
+
if (utils.isString(rawValue)) {
|
1370
|
+
try {
|
1371
|
+
(parser || JSON.parse)(rawValue);
|
1372
|
+
return utils.trim(rawValue);
|
1373
|
+
} catch (e) {
|
1374
|
+
if (e.name !== 'SyntaxError') {
|
1375
|
+
throw e;
|
1376
|
+
}
|
1377
|
+
}
|
1232
1378
|
}
|
1379
|
+
return (encoder || JSON.stringify)(rawValue);
|
1233
1380
|
}
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1381
|
+
var defaults = {
|
1382
|
+
transitional: transitionalDefaults,
|
1383
|
+
adapter: ['xhr', 'http'],
|
1384
|
+
transformRequest: [function transformRequest(data, headers) {
|
1385
|
+
var contentType = headers.getContentType() || '';
|
1386
|
+
var hasJSONContentType = contentType.indexOf('application/json') > -1;
|
1387
|
+
var isObjectPayload = utils.isObject(data);
|
1388
|
+
if (isObjectPayload && utils.isHTMLForm(data)) {
|
1389
|
+
data = new FormData(data);
|
1390
|
+
}
|
1391
|
+
var isFormData = utils.isFormData(data);
|
1392
|
+
if (isFormData) {
|
1393
|
+
if (!hasJSONContentType) {
|
1394
|
+
return data;
|
1244
1395
|
}
|
1245
|
-
|
1246
|
-
|
1396
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
1397
|
+
}
|
1398
|
+
if (utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data)) {
|
1399
|
+
return data;
|
1400
|
+
}
|
1401
|
+
if (utils.isArrayBufferView(data)) {
|
1402
|
+
return data.buffer;
|
1403
|
+
}
|
1404
|
+
if (utils.isURLSearchParams(data)) {
|
1405
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
1406
|
+
return data.toString();
|
1407
|
+
}
|
1408
|
+
var isFileList;
|
1409
|
+
if (isObjectPayload) {
|
1410
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
1411
|
+
return toURLEncodedForm(data, this.formSerializer).toString();
|
1247
1412
|
}
|
1248
|
-
if (utils.
|
1249
|
-
|
1413
|
+
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
1414
|
+
var _FormData = this.env && this.env.FormData;
|
1415
|
+
return toFormData(isFileList ? {
|
1416
|
+
'files[]': data
|
1417
|
+
} : data, _FormData && new _FormData(), this.formSerializer);
|
1250
1418
|
}
|
1251
|
-
|
1252
|
-
|
1419
|
+
}
|
1420
|
+
if (isObjectPayload || hasJSONContentType) {
|
1421
|
+
headers.setContentType('application/json', false);
|
1422
|
+
return stringifySafely(data);
|
1423
|
+
}
|
1424
|
+
return data;
|
1425
|
+
}],
|
1426
|
+
transformResponse: [function transformResponse(data) {
|
1427
|
+
var transitional = this.transitional || defaults.transitional;
|
1428
|
+
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
1429
|
+
var JSONRequested = this.responseType === 'json';
|
1430
|
+
if (data && utils.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
1431
|
+
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
1432
|
+
var strictJSONParsing = !silentJSONParsing && JSONRequested;
|
1433
|
+
try {
|
1434
|
+
return JSON.parse(data);
|
1435
|
+
} catch (e) {
|
1436
|
+
if (strictJSONParsing) {
|
1437
|
+
if (e.name === 'SyntaxError') {
|
1438
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
1439
|
+
}
|
1440
|
+
throw e;
|
1441
|
+
}
|
1253
1442
|
}
|
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
1443
|
}
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1444
|
+
return data;
|
1445
|
+
}],
|
1446
|
+
/**
|
1447
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
1448
|
+
* timeout is not created.
|
1449
|
+
*/
|
1450
|
+
timeout: 0,
|
1451
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
1452
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
1453
|
+
maxContentLength: -1,
|
1454
|
+
maxBodyLength: -1,
|
1455
|
+
env: {
|
1456
|
+
FormData: platform.classes.FormData,
|
1457
|
+
Blob: platform.classes.Blob
|
1458
|
+
},
|
1459
|
+
validateStatus: function validateStatus(status) {
|
1460
|
+
return status >= 200 && status < 300;
|
1461
|
+
},
|
1462
|
+
headers: {
|
1463
|
+
common: {
|
1464
|
+
'Accept': 'application/json, text/plain, */*'
|
1465
|
+
}
|
1466
|
+
}
|
1467
|
+
};
|
1468
|
+
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
1469
|
+
defaults.headers[method] = {};
|
1470
|
+
});
|
1471
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
1472
|
+
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
1473
|
+
});
|
1474
|
+
var defaults$1 = defaults;
|
1275
1475
|
|
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
|
-
}
|
1476
|
+
// RawAxiosHeaders whose duplicates are ignored by node
|
1477
|
+
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
1478
|
+
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
1479
|
|
1290
1480
|
/**
|
1291
|
-
*
|
1292
|
-
*
|
1293
|
-
* @param {string} baseURL The base URL
|
1294
|
-
* @param {string} relativeURL The relative URL
|
1481
|
+
* Parse headers into an object
|
1295
1482
|
*
|
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.
|
1483
|
+
* ```
|
1484
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
1485
|
+
* Content-Type: application/json
|
1486
|
+
* Connection: keep-alive
|
1487
|
+
* Transfer-Encoding: chunked
|
1488
|
+
* ```
|
1306
1489
|
*
|
1307
|
-
* @param {
|
1308
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
1490
|
+
* @param {String} rawHeaders Headers needing to be parsed
|
1309
1491
|
*
|
1310
|
-
* @returns {
|
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
|
1412
|
-
*
|
1413
|
-
* @returns {Object} Headers parsed into an object
|
1492
|
+
* @returns {Object} Headers parsed into an object
|
1414
1493
|
*/
|
1415
1494
|
var parseHeaders = (function (rawHeaders) {
|
1416
1495
|
var parsed = {};
|
@@ -1438,7 +1517,6 @@
|
|
1438
1517
|
});
|
1439
1518
|
|
1440
1519
|
var $internals = Symbol('internals');
|
1441
|
-
var $defaults = Symbol('defaults');
|
1442
1520
|
function normalizeHeader(header) {
|
1443
1521
|
return header && String(header).trim().toLowerCase();
|
1444
1522
|
}
|
@@ -1457,10 +1535,16 @@
|
|
1457
1535
|
}
|
1458
1536
|
return tokens;
|
1459
1537
|
}
|
1460
|
-
function
|
1538
|
+
function isValidHeaderName(str) {
|
1539
|
+
return /^[-_a-zA-Z]+$/.test(str.trim());
|
1540
|
+
}
|
1541
|
+
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
1461
1542
|
if (utils.isFunction(filter)) {
|
1462
1543
|
return filter.call(this, value, header);
|
1463
1544
|
}
|
1545
|
+
if (isHeaderNameFilter) {
|
1546
|
+
value = header;
|
1547
|
+
}
|
1464
1548
|
if (!utils.isString(value)) return;
|
1465
1549
|
if (utils.isString(filter)) {
|
1466
1550
|
return value.indexOf(filter) !== -1;
|
@@ -1485,153 +1569,415 @@
|
|
1485
1569
|
});
|
1486
1570
|
});
|
1487
1571
|
}
|
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
|
-
}
|
1572
|
+
var AxiosHeaders = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
|
1573
|
+
function AxiosHeaders(headers) {
|
1574
|
+
_classCallCheck(this, AxiosHeaders);
|
1575
|
+
headers && this.set(headers);
|
1498
1576
|
}
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1577
|
+
_createClass(AxiosHeaders, [{
|
1578
|
+
key: "set",
|
1579
|
+
value: function set(header, valueOrRewrite, rewrite) {
|
1580
|
+
var self = this;
|
1581
|
+
function setHeader(_value, _header, _rewrite) {
|
1582
|
+
var lHeader = normalizeHeader(_header);
|
1583
|
+
if (!lHeader) {
|
1584
|
+
throw new Error('header name must be a non-empty string');
|
1585
|
+
}
|
1586
|
+
var key = utils.findKey(self, lHeader);
|
1587
|
+
if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
|
1588
|
+
self[key || _header] = normalizeValue(_value);
|
1589
|
+
}
|
1512
1590
|
}
|
1513
|
-
var
|
1514
|
-
|
1515
|
-
|
1591
|
+
var setHeaders = function setHeaders(headers, _rewrite) {
|
1592
|
+
return utils.forEach(headers, function (_value, _header) {
|
1593
|
+
return setHeader(_value, _header, _rewrite);
|
1594
|
+
});
|
1595
|
+
};
|
1596
|
+
if (utils.isPlainObject(header) || header instanceof this.constructor) {
|
1597
|
+
setHeaders(header, valueOrRewrite);
|
1598
|
+
} else if (utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
1599
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
1600
|
+
} else {
|
1601
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
1516
1602
|
}
|
1517
|
-
|
1603
|
+
return this;
|
1518
1604
|
}
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1605
|
+
}, {
|
1606
|
+
key: "get",
|
1607
|
+
value: function get(header, parser) {
|
1608
|
+
header = normalizeHeader(header);
|
1609
|
+
if (header) {
|
1610
|
+
var key = utils.findKey(this, header);
|
1611
|
+
if (key) {
|
1612
|
+
var value = this[key];
|
1613
|
+
if (!parser) {
|
1614
|
+
return value;
|
1615
|
+
}
|
1616
|
+
if (parser === true) {
|
1617
|
+
return parseTokens(value);
|
1618
|
+
}
|
1619
|
+
if (utils.isFunction(parser)) {
|
1620
|
+
return parser.call(this, value, key);
|
1621
|
+
}
|
1622
|
+
if (utils.isRegExp(parser)) {
|
1623
|
+
return parser.exec(value);
|
1624
|
+
}
|
1625
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
1626
|
+
}
|
1536
1627
|
}
|
1537
|
-
|
1538
|
-
|
1628
|
+
}
|
1629
|
+
}, {
|
1630
|
+
key: "has",
|
1631
|
+
value: function has(header, matcher) {
|
1632
|
+
header = normalizeHeader(header);
|
1633
|
+
if (header) {
|
1634
|
+
var key = utils.findKey(this, header);
|
1635
|
+
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1539
1636
|
}
|
1540
|
-
|
1541
|
-
|
1637
|
+
return false;
|
1638
|
+
}
|
1639
|
+
}, {
|
1640
|
+
key: "delete",
|
1641
|
+
value: function _delete(header, matcher) {
|
1642
|
+
var self = this;
|
1643
|
+
var deleted = false;
|
1644
|
+
function deleteHeader(_header) {
|
1645
|
+
_header = normalizeHeader(_header);
|
1646
|
+
if (_header) {
|
1647
|
+
var key = utils.findKey(self, _header);
|
1648
|
+
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
1649
|
+
delete self[key];
|
1650
|
+
deleted = true;
|
1651
|
+
}
|
1652
|
+
}
|
1542
1653
|
}
|
1543
|
-
if (utils.
|
1544
|
-
|
1654
|
+
if (utils.isArray(header)) {
|
1655
|
+
header.forEach(deleteHeader);
|
1656
|
+
} else {
|
1657
|
+
deleteHeader(header);
|
1545
1658
|
}
|
1546
|
-
|
1659
|
+
return deleted;
|
1547
1660
|
}
|
1548
|
-
},
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
var
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
var self = this;
|
1559
|
-
var deleted = false;
|
1560
|
-
function deleteHeader(_header) {
|
1561
|
-
_header = normalizeHeader(_header);
|
1562
|
-
if (_header) {
|
1563
|
-
var key = findKey(self, _header);
|
1564
|
-
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
1565
|
-
delete self[key];
|
1661
|
+
}, {
|
1662
|
+
key: "clear",
|
1663
|
+
value: function clear(matcher) {
|
1664
|
+
var keys = Object.keys(this);
|
1665
|
+
var i = keys.length;
|
1666
|
+
var deleted = false;
|
1667
|
+
while (i--) {
|
1668
|
+
var key = keys[i];
|
1669
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
1670
|
+
delete this[key];
|
1566
1671
|
deleted = true;
|
1567
1672
|
}
|
1568
1673
|
}
|
1674
|
+
return deleted;
|
1569
1675
|
}
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1676
|
+
}, {
|
1677
|
+
key: "normalize",
|
1678
|
+
value: function normalize(format) {
|
1679
|
+
var self = this;
|
1680
|
+
var headers = {};
|
1681
|
+
utils.forEach(this, function (value, header) {
|
1682
|
+
var key = utils.findKey(headers, header);
|
1683
|
+
if (key) {
|
1684
|
+
self[key] = normalizeValue(value);
|
1685
|
+
delete self[header];
|
1686
|
+
return;
|
1687
|
+
}
|
1688
|
+
var normalized = format ? formatHeader(header) : String(header).trim();
|
1689
|
+
if (normalized !== header) {
|
1690
|
+
delete self[header];
|
1691
|
+
}
|
1692
|
+
self[normalized] = normalizeValue(value);
|
1693
|
+
headers[normalized] = true;
|
1694
|
+
});
|
1695
|
+
return this;
|
1574
1696
|
}
|
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;
|
1697
|
+
}, {
|
1698
|
+
key: "concat",
|
1699
|
+
value: function concat() {
|
1700
|
+
var _this$constructor;
|
1701
|
+
for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
|
1702
|
+
targets[_key] = arguments[_key];
|
1589
1703
|
}
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1704
|
+
return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
|
1705
|
+
}
|
1706
|
+
}, {
|
1707
|
+
key: "toJSON",
|
1708
|
+
value: function toJSON(asStrings) {
|
1709
|
+
var obj = Object.create(null);
|
1710
|
+
utils.forEach(this, function (value, header) {
|
1711
|
+
value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
|
1712
|
+
});
|
1713
|
+
return obj;
|
1714
|
+
}
|
1715
|
+
}, {
|
1716
|
+
key: _Symbol$iterator,
|
1717
|
+
value: function value() {
|
1718
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
1719
|
+
}
|
1720
|
+
}, {
|
1721
|
+
key: "toString",
|
1722
|
+
value: function toString() {
|
1723
|
+
return Object.entries(this.toJSON()).map(function (_ref) {
|
1724
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
1725
|
+
header = _ref2[0],
|
1726
|
+
value = _ref2[1];
|
1727
|
+
return header + ': ' + value;
|
1728
|
+
}).join('\n');
|
1729
|
+
}
|
1730
|
+
}, {
|
1731
|
+
key: _Symbol$toStringTag,
|
1732
|
+
get: function get() {
|
1733
|
+
return 'AxiosHeaders';
|
1734
|
+
}
|
1735
|
+
}], [{
|
1736
|
+
key: "from",
|
1737
|
+
value: function from(thing) {
|
1738
|
+
return thing instanceof this ? thing : new this(thing);
|
1739
|
+
}
|
1740
|
+
}, {
|
1741
|
+
key: "concat",
|
1742
|
+
value: function concat(first) {
|
1743
|
+
var computed = new this(first);
|
1744
|
+
for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
1745
|
+
targets[_key2 - 1] = arguments[_key2];
|
1593
1746
|
}
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1747
|
+
targets.forEach(function (target) {
|
1748
|
+
return computed.set(target);
|
1749
|
+
});
|
1750
|
+
return computed;
|
1751
|
+
}
|
1752
|
+
}, {
|
1753
|
+
key: "accessor",
|
1754
|
+
value: function accessor(header) {
|
1755
|
+
var internals = this[$internals] = this[$internals] = {
|
1756
|
+
accessors: {}
|
1757
|
+
};
|
1758
|
+
var accessors = internals.accessors;
|
1759
|
+
var prototype = this.prototype;
|
1760
|
+
function defineAccessor(_header) {
|
1761
|
+
var lHeader = normalizeHeader(_header);
|
1762
|
+
if (!accessors[lHeader]) {
|
1763
|
+
buildAccessors(prototype, _header);
|
1764
|
+
accessors[lHeader] = true;
|
1765
|
+
}
|
1766
|
+
}
|
1767
|
+
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
1768
|
+
return this;
|
1769
|
+
}
|
1770
|
+
}]);
|
1771
|
+
return AxiosHeaders;
|
1772
|
+
}(Symbol.iterator, Symbol.toStringTag);
|
1773
|
+
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
1774
|
+
utils.freezeMethods(AxiosHeaders.prototype);
|
1775
|
+
utils.freezeMethods(AxiosHeaders);
|
1776
|
+
var AxiosHeaders$1 = AxiosHeaders;
|
1777
|
+
|
1778
|
+
/**
|
1779
|
+
* Transform the data for a request or a response
|
1780
|
+
*
|
1781
|
+
* @param {Array|Function} fns A single function or Array of functions
|
1782
|
+
* @param {?Object} response The response object
|
1783
|
+
*
|
1784
|
+
* @returns {*} The resulting transformed data
|
1785
|
+
*/
|
1786
|
+
function transformData(fns, response) {
|
1787
|
+
var config = this || defaults$1;
|
1788
|
+
var context = response || config;
|
1789
|
+
var headers = AxiosHeaders$1.from(context.headers);
|
1790
|
+
var data = context.data;
|
1791
|
+
utils.forEach(fns, function transform(fn) {
|
1792
|
+
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
1793
|
+
});
|
1794
|
+
headers.normalize();
|
1795
|
+
return data;
|
1796
|
+
}
|
1797
|
+
|
1798
|
+
function isCancel(value) {
|
1799
|
+
return !!(value && value.__CANCEL__);
|
1800
|
+
}
|
1801
|
+
|
1802
|
+
/**
|
1803
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
1804
|
+
*
|
1805
|
+
* @param {string=} message The message.
|
1806
|
+
* @param {Object=} config The config.
|
1807
|
+
* @param {Object=} request The request.
|
1808
|
+
*
|
1809
|
+
* @returns {CanceledError} The created error.
|
1810
|
+
*/
|
1811
|
+
function CanceledError(message, config, request) {
|
1812
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
1813
|
+
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
1814
|
+
this.name = 'CanceledError';
|
1815
|
+
}
|
1816
|
+
utils.inherits(CanceledError, AxiosError, {
|
1817
|
+
__CANCEL__: true
|
1818
|
+
});
|
1819
|
+
|
1820
|
+
/**
|
1821
|
+
* Resolve or reject a Promise based on response status.
|
1822
|
+
*
|
1823
|
+
* @param {Function} resolve A function that resolves the promise.
|
1824
|
+
* @param {Function} reject A function that rejects the promise.
|
1825
|
+
* @param {object} response The response.
|
1826
|
+
*
|
1827
|
+
* @returns {object} The response.
|
1828
|
+
*/
|
1829
|
+
function settle(resolve, reject, response) {
|
1830
|
+
var validateStatus = response.config.validateStatus;
|
1831
|
+
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
1832
|
+
resolve(response);
|
1833
|
+
} else {
|
1834
|
+
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));
|
1835
|
+
}
|
1836
|
+
}
|
1837
|
+
|
1838
|
+
var cookies = platform.isStandardBrowserEnv ?
|
1839
|
+
// Standard browser envs support document.cookie
|
1840
|
+
function standardBrowserEnv() {
|
1841
|
+
return {
|
1842
|
+
write: function write(name, value, expires, path, domain, secure) {
|
1843
|
+
var cookie = [];
|
1844
|
+
cookie.push(name + '=' + encodeURIComponent(value));
|
1845
|
+
if (utils.isNumber(expires)) {
|
1846
|
+
cookie.push('expires=' + new Date(expires).toGMTString());
|
1847
|
+
}
|
1848
|
+
if (utils.isString(path)) {
|
1849
|
+
cookie.push('path=' + path);
|
1850
|
+
}
|
1851
|
+
if (utils.isString(domain)) {
|
1852
|
+
cookie.push('domain=' + domain);
|
1853
|
+
}
|
1854
|
+
if (secure === true) {
|
1855
|
+
cookie.push('secure');
|
1856
|
+
}
|
1857
|
+
document.cookie = cookie.join('; ');
|
1858
|
+
},
|
1859
|
+
read: function read(name) {
|
1860
|
+
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
1861
|
+
return match ? decodeURIComponent(match[3]) : null;
|
1862
|
+
},
|
1863
|
+
remove: function remove(name) {
|
1864
|
+
this.write(name, '', Date.now() - 86400000);
|
1865
|
+
}
|
1866
|
+
};
|
1867
|
+
}() :
|
1868
|
+
// Non standard browser env (web workers, react-native) lack needed support.
|
1869
|
+
function nonStandardBrowserEnv() {
|
1870
|
+
return {
|
1871
|
+
write: function write() {},
|
1872
|
+
read: function read() {
|
1873
|
+
return null;
|
1874
|
+
},
|
1875
|
+
remove: function remove() {}
|
1876
|
+
};
|
1877
|
+
}();
|
1878
|
+
|
1879
|
+
/**
|
1880
|
+
* Determines whether the specified URL is absolute
|
1881
|
+
*
|
1882
|
+
* @param {string} url The URL to test
|
1883
|
+
*
|
1884
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
1885
|
+
*/
|
1886
|
+
function isAbsoluteURL(url) {
|
1887
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
1888
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
1889
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
1890
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
1891
|
+
}
|
1892
|
+
|
1893
|
+
/**
|
1894
|
+
* Creates a new URL by combining the specified URLs
|
1895
|
+
*
|
1896
|
+
* @param {string} baseURL The base URL
|
1897
|
+
* @param {string} relativeURL The relative URL
|
1898
|
+
*
|
1899
|
+
* @returns {string} The combined URL
|
1900
|
+
*/
|
1901
|
+
function combineURLs(baseURL, relativeURL) {
|
1902
|
+
return relativeURL ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
|
1903
|
+
}
|
1904
|
+
|
1905
|
+
/**
|
1906
|
+
* Creates a new URL by combining the baseURL with the requestedURL,
|
1907
|
+
* only when the requestedURL is not already an absolute URL.
|
1908
|
+
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
1909
|
+
*
|
1910
|
+
* @param {string} baseURL The base URL
|
1911
|
+
* @param {string} requestedURL Absolute or relative URL to combine
|
1912
|
+
*
|
1913
|
+
* @returns {string} The combined full path
|
1914
|
+
*/
|
1915
|
+
function buildFullPath(baseURL, requestedURL) {
|
1916
|
+
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
1917
|
+
return combineURLs(baseURL, requestedURL);
|
1606
1918
|
}
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1919
|
+
return requestedURL;
|
1920
|
+
}
|
1921
|
+
|
1922
|
+
var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
1923
|
+
// Standard browser envs have full support of the APIs needed to test
|
1924
|
+
// whether the request URL is of the same origin as current location.
|
1925
|
+
function standardBrowserEnv() {
|
1926
|
+
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
1927
|
+
var urlParsingNode = document.createElement('a');
|
1928
|
+
var originURL;
|
1929
|
+
|
1930
|
+
/**
|
1931
|
+
* Parse a URL to discover it's components
|
1932
|
+
*
|
1933
|
+
* @param {String} url The URL to be parsed
|
1934
|
+
* @returns {Object}
|
1935
|
+
*/
|
1936
|
+
function resolveURL(url) {
|
1937
|
+
var href = url;
|
1938
|
+
if (msie) {
|
1939
|
+
// IE needs attribute set twice to normalize properties
|
1940
|
+
urlParsingNode.setAttribute('href', href);
|
1941
|
+
href = urlParsingNode.href;
|
1612
1942
|
}
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1943
|
+
urlParsingNode.setAttribute('href', href);
|
1944
|
+
|
1945
|
+
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
1946
|
+
return {
|
1947
|
+
href: urlParsingNode.href,
|
1948
|
+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
1949
|
+
host: urlParsingNode.host,
|
1950
|
+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
1951
|
+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
1952
|
+
hostname: urlParsingNode.hostname,
|
1953
|
+
port: urlParsingNode.port,
|
1954
|
+
pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname
|
1618
1955
|
};
|
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
1956
|
}
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1957
|
+
originURL = resolveURL(window.location.href);
|
1958
|
+
|
1959
|
+
/**
|
1960
|
+
* Determine if a URL shares the same origin as the current location
|
1961
|
+
*
|
1962
|
+
* @param {String} requestURL The URL to test
|
1963
|
+
* @returns {boolean} True if URL shares the same origin, otherwise false
|
1964
|
+
*/
|
1965
|
+
return function isURLSameOrigin(requestURL) {
|
1966
|
+
var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
1967
|
+
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
1968
|
+
};
|
1969
|
+
}() :
|
1970
|
+
// Non standard browser envs (web workers, react-native) lack needed support.
|
1971
|
+
function nonStandardBrowserEnv() {
|
1972
|
+
return function isURLSameOrigin() {
|
1973
|
+
return true;
|
1974
|
+
};
|
1975
|
+
}();
|
1976
|
+
|
1977
|
+
function parseProtocol(url) {
|
1978
|
+
var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
1979
|
+
return match && match[1] || '';
|
1980
|
+
}
|
1635
1981
|
|
1636
1982
|
/**
|
1637
1983
|
* Calculate data maxRate
|
@@ -1689,16 +2035,18 @@
|
|
1689
2035
|
progress: total ? loaded / total : undefined,
|
1690
2036
|
bytes: progressBytes,
|
1691
2037
|
rate: rate ? rate : undefined,
|
1692
|
-
estimated: rate && total && inRange ? (total - loaded) / rate : undefined
|
2038
|
+
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
2039
|
+
event: e
|
1693
2040
|
};
|
1694
2041
|
data[isDownloadStream ? 'download' : 'upload'] = true;
|
1695
2042
|
listener(data);
|
1696
2043
|
};
|
1697
2044
|
}
|
1698
|
-
|
2045
|
+
var isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
2046
|
+
var xhrAdapter = isXHRAdapterSupported && function (config) {
|
1699
2047
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
1700
2048
|
var requestData = config.data;
|
1701
|
-
var requestHeaders = AxiosHeaders.from(config.headers).normalize();
|
2049
|
+
var requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
|
1702
2050
|
var responseType = config.responseType;
|
1703
2051
|
var onCanceled;
|
1704
2052
|
function done() {
|
@@ -1709,7 +2057,7 @@
|
|
1709
2057
|
config.signal.removeEventListener('abort', onCanceled);
|
1710
2058
|
}
|
1711
2059
|
}
|
1712
|
-
if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
|
2060
|
+
if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
|
1713
2061
|
requestHeaders.setContentType(false); // Let the browser set it
|
1714
2062
|
}
|
1715
2063
|
|
@@ -1731,7 +2079,7 @@
|
|
1731
2079
|
return;
|
1732
2080
|
}
|
1733
2081
|
// Prepare the response
|
1734
|
-
var responseHeaders = AxiosHeaders.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
|
2082
|
+
var responseHeaders = AxiosHeaders$1.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
|
1735
2083
|
var responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
|
1736
2084
|
var response = {
|
1737
2085
|
data: responseData,
|
@@ -1874,191 +2222,52 @@
|
|
1874
2222
|
// Send the request
|
1875
2223
|
request.send(requestData || null);
|
1876
2224
|
});
|
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
2225
|
};
|
1899
2226
|
|
1900
|
-
var
|
1901
|
-
|
2227
|
+
var knownAdapters = {
|
2228
|
+
http: httpAdapter,
|
2229
|
+
xhr: xhrAdapter
|
1902
2230
|
};
|
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)) {
|
2231
|
+
utils.forEach(knownAdapters, function (fn, value) {
|
2232
|
+
if (fn) {
|
1934
2233
|
try {
|
1935
|
-
(
|
1936
|
-
|
2234
|
+
Object.defineProperty(fn, 'name', {
|
2235
|
+
value: value
|
2236
|
+
});
|
1937
2237
|
} catch (e) {
|
1938
|
-
|
1939
|
-
throw e;
|
1940
|
-
}
|
2238
|
+
// eslint-disable-next-line no-empty
|
1941
2239
|
}
|
2240
|
+
Object.defineProperty(fn, 'adapterName', {
|
2241
|
+
value: value
|
2242
|
+
});
|
1942
2243
|
}
|
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;
|
2244
|
+
});
|
2245
|
+
var adapters = {
|
2246
|
+
getAdapter: function getAdapter(adapters) {
|
2247
|
+
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
2248
|
+
var _adapters = adapters,
|
2249
|
+
length = _adapters.length;
|
2250
|
+
var nameOrAdapter;
|
2251
|
+
var adapter;
|
2252
|
+
for (var i = 0; i < length; i++) {
|
2253
|
+
nameOrAdapter = adapters[i];
|
2254
|
+
if (adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter) {
|
2255
|
+
break;
|
1959
2256
|
}
|
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
2257
|
}
|
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();
|
2258
|
+
if (!adapter) {
|
2259
|
+
if (adapter === false) {
|
2260
|
+
throw new AxiosError("Adapter ".concat(nameOrAdapter, " is not supported by the environment"), 'ERR_NOT_SUPPORT');
|
1976
2261
|
}
|
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);
|
2262
|
+
throw new Error(utils.hasOwnProp(knownAdapters, nameOrAdapter) ? "Adapter '".concat(nameOrAdapter, "' is not available in the build") : "Unknown adapter '".concat(nameOrAdapter, "'"));
|
1987
2263
|
}
|
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
|
-
}
|
2264
|
+
if (!utils.isFunction(adapter)) {
|
2265
|
+
throw new TypeError('adapter is not a function');
|
2007
2266
|
}
|
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
|
2267
|
+
return adapter;
|
2022
2268
|
},
|
2023
|
-
|
2024
|
-
return status >= 200 && status < 300;
|
2025
|
-
},
|
2026
|
-
headers: {
|
2027
|
-
common: {
|
2028
|
-
'Accept': 'application/json, text/plain, */*'
|
2029
|
-
}
|
2030
|
-
}
|
2269
|
+
adapters: knownAdapters
|
2031
2270
|
};
|
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
2271
|
|
2063
2272
|
/**
|
2064
2273
|
* Throws a `CanceledError` if cancellation has been requested.
|
@@ -2072,7 +2281,7 @@
|
|
2072
2281
|
config.cancelToken.throwIfRequested();
|
2073
2282
|
}
|
2074
2283
|
if (config.signal && config.signal.aborted) {
|
2075
|
-
throw new CanceledError();
|
2284
|
+
throw new CanceledError(null, config);
|
2076
2285
|
}
|
2077
2286
|
}
|
2078
2287
|
|
@@ -2085,17 +2294,20 @@
|
|
2085
2294
|
*/
|
2086
2295
|
function dispatchRequest(config) {
|
2087
2296
|
throwIfCancellationRequested(config);
|
2088
|
-
config.headers = AxiosHeaders.from(config.headers);
|
2297
|
+
config.headers = AxiosHeaders$1.from(config.headers);
|
2089
2298
|
|
2090
2299
|
// Transform request data
|
2091
2300
|
config.data = transformData.call(config, config.transformRequest);
|
2092
|
-
|
2301
|
+
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
2302
|
+
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
2303
|
+
}
|
2304
|
+
var adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
2093
2305
|
return adapter(config).then(function onAdapterResolution(response) {
|
2094
2306
|
throwIfCancellationRequested(config);
|
2095
2307
|
|
2096
2308
|
// Transform response data
|
2097
2309
|
response.data = transformData.call(config, config.transformResponse, response);
|
2098
|
-
response.headers = AxiosHeaders.from(response.headers);
|
2310
|
+
response.headers = AxiosHeaders$1.from(response.headers);
|
2099
2311
|
return response;
|
2100
2312
|
}, function onAdapterRejection(reason) {
|
2101
2313
|
if (!isCancel(reason)) {
|
@@ -2104,13 +2316,17 @@
|
|
2104
2316
|
// Transform response data
|
2105
2317
|
if (reason && reason.response) {
|
2106
2318
|
reason.response.data = transformData.call(config, config.transformResponse, reason.response);
|
2107
|
-
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
2319
|
+
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
2108
2320
|
}
|
2109
2321
|
}
|
2110
2322
|
return Promise.reject(reason);
|
2111
2323
|
});
|
2112
2324
|
}
|
2113
2325
|
|
2326
|
+
var headersToObject = function headersToObject(thing) {
|
2327
|
+
return thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
|
2328
|
+
};
|
2329
|
+
|
2114
2330
|
/**
|
2115
2331
|
* Config-specific merge-function which creates a new config-object
|
2116
2332
|
* by merging two configuration objects together.
|
@@ -2124,9 +2340,11 @@
|
|
2124
2340
|
// eslint-disable-next-line no-param-reassign
|
2125
2341
|
config2 = config2 || {};
|
2126
2342
|
var config = {};
|
2127
|
-
function getMergedValue(target, source) {
|
2343
|
+
function getMergedValue(target, source, caseless) {
|
2128
2344
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
2129
|
-
return utils.merge(
|
2345
|
+
return utils.merge.call({
|
2346
|
+
caseless: caseless
|
2347
|
+
}, target, source);
|
2130
2348
|
} else if (utils.isPlainObject(source)) {
|
2131
2349
|
return utils.merge({}, source);
|
2132
2350
|
} else if (utils.isArray(source)) {
|
@@ -2136,76 +2354,79 @@
|
|
2136
2354
|
}
|
2137
2355
|
|
2138
2356
|
// 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,
|
2357
|
+
function mergeDeepProperties(a, b, caseless) {
|
2358
|
+
if (!utils.isUndefined(b)) {
|
2359
|
+
return getMergedValue(a, b, caseless);
|
2360
|
+
} else if (!utils.isUndefined(a)) {
|
2361
|
+
return getMergedValue(undefined, a, caseless);
|
2144
2362
|
}
|
2145
2363
|
}
|
2146
2364
|
|
2147
2365
|
// eslint-disable-next-line consistent-return
|
2148
|
-
function valueFromConfig2(
|
2149
|
-
if (!utils.isUndefined(
|
2150
|
-
return getMergedValue(undefined,
|
2366
|
+
function valueFromConfig2(a, b) {
|
2367
|
+
if (!utils.isUndefined(b)) {
|
2368
|
+
return getMergedValue(undefined, b);
|
2151
2369
|
}
|
2152
2370
|
}
|
2153
2371
|
|
2154
2372
|
// 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,
|
2373
|
+
function defaultToConfig2(a, b) {
|
2374
|
+
if (!utils.isUndefined(b)) {
|
2375
|
+
return getMergedValue(undefined, b);
|
2376
|
+
} else if (!utils.isUndefined(a)) {
|
2377
|
+
return getMergedValue(undefined, a);
|
2160
2378
|
}
|
2161
2379
|
}
|
2162
2380
|
|
2163
2381
|
// eslint-disable-next-line consistent-return
|
2164
|
-
function mergeDirectKeys(prop) {
|
2382
|
+
function mergeDirectKeys(a, b, prop) {
|
2165
2383
|
if (prop in config2) {
|
2166
|
-
return getMergedValue(
|
2384
|
+
return getMergedValue(a, b);
|
2167
2385
|
} else if (prop in config1) {
|
2168
|
-
return getMergedValue(undefined,
|
2386
|
+
return getMergedValue(undefined, a);
|
2169
2387
|
}
|
2170
2388
|
}
|
2171
2389
|
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
|
-
|
2390
|
+
url: valueFromConfig2,
|
2391
|
+
method: valueFromConfig2,
|
2392
|
+
data: valueFromConfig2,
|
2393
|
+
baseURL: defaultToConfig2,
|
2394
|
+
transformRequest: defaultToConfig2,
|
2395
|
+
transformResponse: defaultToConfig2,
|
2396
|
+
paramsSerializer: defaultToConfig2,
|
2397
|
+
timeout: defaultToConfig2,
|
2398
|
+
timeoutMessage: defaultToConfig2,
|
2399
|
+
withCredentials: defaultToConfig2,
|
2400
|
+
adapter: defaultToConfig2,
|
2401
|
+
responseType: defaultToConfig2,
|
2402
|
+
xsrfCookieName: defaultToConfig2,
|
2403
|
+
xsrfHeaderName: defaultToConfig2,
|
2404
|
+
onUploadProgress: defaultToConfig2,
|
2405
|
+
onDownloadProgress: defaultToConfig2,
|
2406
|
+
decompress: defaultToConfig2,
|
2407
|
+
maxContentLength: defaultToConfig2,
|
2408
|
+
maxBodyLength: defaultToConfig2,
|
2409
|
+
beforeRedirect: defaultToConfig2,
|
2410
|
+
transport: defaultToConfig2,
|
2411
|
+
httpAgent: defaultToConfig2,
|
2412
|
+
httpsAgent: defaultToConfig2,
|
2413
|
+
cancelToken: defaultToConfig2,
|
2414
|
+
socketPath: defaultToConfig2,
|
2415
|
+
responseEncoding: defaultToConfig2,
|
2416
|
+
validateStatus: mergeDirectKeys,
|
2417
|
+
headers: function headers(a, b) {
|
2418
|
+
return mergeDeepProperties(headersToObject(a), headersToObject(b), true);
|
2419
|
+
}
|
2199
2420
|
};
|
2200
2421
|
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
2201
2422
|
var merge = mergeMap[prop] || mergeDeepProperties;
|
2202
|
-
var configValue = merge(prop);
|
2423
|
+
var configValue = merge(config1[prop], config2[prop], prop);
|
2203
2424
|
utils.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
|
2204
2425
|
});
|
2205
2426
|
return config;
|
2206
2427
|
}
|
2207
2428
|
|
2208
|
-
var VERSION = "1.
|
2429
|
+
var VERSION = "1.3.3";
|
2209
2430
|
|
2210
2431
|
var validators$1 = {};
|
2211
2432
|
|
@@ -2296,8 +2517,8 @@
|
|
2296
2517
|
_classCallCheck(this, Axios);
|
2297
2518
|
this.defaults = instanceConfig;
|
2298
2519
|
this.interceptors = {
|
2299
|
-
request: new InterceptorManager(),
|
2300
|
-
response: new InterceptorManager()
|
2520
|
+
request: new InterceptorManager$1(),
|
2521
|
+
response: new InterceptorManager$1()
|
2301
2522
|
};
|
2302
2523
|
}
|
2303
2524
|
|
@@ -2323,7 +2544,8 @@
|
|
2323
2544
|
config = mergeConfig(this.defaults, config);
|
2324
2545
|
var _config = config,
|
2325
2546
|
transitional = _config.transitional,
|
2326
|
-
paramsSerializer = _config.paramsSerializer
|
2547
|
+
paramsSerializer = _config.paramsSerializer,
|
2548
|
+
headers = _config.headers;
|
2327
2549
|
if (transitional !== undefined) {
|
2328
2550
|
validator.assertOptions(transitional, {
|
2329
2551
|
silentJSONParsing: validators.transitional(validators["boolean"]),
|
@@ -2340,13 +2562,14 @@
|
|
2340
2562
|
|
2341
2563
|
// Set config.method
|
2342
2564
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
2565
|
+
var contextHeaders;
|
2343
2566
|
|
2344
2567
|
// Flatten headers
|
2345
|
-
|
2346
|
-
|
2347
|
-
delete
|
2568
|
+
contextHeaders = headers && utils.merge(headers.common, headers[config.method]);
|
2569
|
+
contextHeaders && utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function (method) {
|
2570
|
+
delete headers[method];
|
2348
2571
|
});
|
2349
|
-
config.headers =
|
2572
|
+
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
2350
2573
|
|
2351
2574
|
// filter out skipped interceptors
|
2352
2575
|
var requestInterceptorChain = [];
|
@@ -2439,6 +2662,7 @@
|
|
2439
2662
|
Axios.prototype[method] = generateHTTPMethod();
|
2440
2663
|
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
2441
2664
|
});
|
2665
|
+
var Axios$1 = Axios;
|
2442
2666
|
|
2443
2667
|
/**
|
2444
2668
|
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
@@ -2554,6 +2778,7 @@
|
|
2554
2778
|
}]);
|
2555
2779
|
return CancelToken;
|
2556
2780
|
}();
|
2781
|
+
var CancelToken$1 = CancelToken;
|
2557
2782
|
|
2558
2783
|
/**
|
2559
2784
|
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
@@ -2593,6 +2818,79 @@
|
|
2593
2818
|
return utils.isObject(payload) && payload.isAxiosError === true;
|
2594
2819
|
}
|
2595
2820
|
|
2821
|
+
var HttpStatusCode = {
|
2822
|
+
Continue: 100,
|
2823
|
+
SwitchingProtocols: 101,
|
2824
|
+
Processing: 102,
|
2825
|
+
EarlyHints: 103,
|
2826
|
+
Ok: 200,
|
2827
|
+
Created: 201,
|
2828
|
+
Accepted: 202,
|
2829
|
+
NonAuthoritativeInformation: 203,
|
2830
|
+
NoContent: 204,
|
2831
|
+
ResetContent: 205,
|
2832
|
+
PartialContent: 206,
|
2833
|
+
MultiStatus: 207,
|
2834
|
+
AlreadyReported: 208,
|
2835
|
+
ImUsed: 226,
|
2836
|
+
MultipleChoices: 300,
|
2837
|
+
MovedPermanently: 301,
|
2838
|
+
Found: 302,
|
2839
|
+
SeeOther: 303,
|
2840
|
+
NotModified: 304,
|
2841
|
+
UseProxy: 305,
|
2842
|
+
Unused: 306,
|
2843
|
+
TemporaryRedirect: 307,
|
2844
|
+
PermanentRedirect: 308,
|
2845
|
+
BadRequest: 400,
|
2846
|
+
Unauthorized: 401,
|
2847
|
+
PaymentRequired: 402,
|
2848
|
+
Forbidden: 403,
|
2849
|
+
NotFound: 404,
|
2850
|
+
MethodNotAllowed: 405,
|
2851
|
+
NotAcceptable: 406,
|
2852
|
+
ProxyAuthenticationRequired: 407,
|
2853
|
+
RequestTimeout: 408,
|
2854
|
+
Conflict: 409,
|
2855
|
+
Gone: 410,
|
2856
|
+
LengthRequired: 411,
|
2857
|
+
PreconditionFailed: 412,
|
2858
|
+
PayloadTooLarge: 413,
|
2859
|
+
UriTooLong: 414,
|
2860
|
+
UnsupportedMediaType: 415,
|
2861
|
+
RangeNotSatisfiable: 416,
|
2862
|
+
ExpectationFailed: 417,
|
2863
|
+
ImATeapot: 418,
|
2864
|
+
MisdirectedRequest: 421,
|
2865
|
+
UnprocessableEntity: 422,
|
2866
|
+
Locked: 423,
|
2867
|
+
FailedDependency: 424,
|
2868
|
+
TooEarly: 425,
|
2869
|
+
UpgradeRequired: 426,
|
2870
|
+
PreconditionRequired: 428,
|
2871
|
+
TooManyRequests: 429,
|
2872
|
+
RequestHeaderFieldsTooLarge: 431,
|
2873
|
+
UnavailableForLegalReasons: 451,
|
2874
|
+
InternalServerError: 500,
|
2875
|
+
NotImplemented: 501,
|
2876
|
+
BadGateway: 502,
|
2877
|
+
ServiceUnavailable: 503,
|
2878
|
+
GatewayTimeout: 504,
|
2879
|
+
HttpVersionNotSupported: 505,
|
2880
|
+
VariantAlsoNegotiates: 506,
|
2881
|
+
InsufficientStorage: 507,
|
2882
|
+
LoopDetected: 508,
|
2883
|
+
NotExtended: 510,
|
2884
|
+
NetworkAuthenticationRequired: 511
|
2885
|
+
};
|
2886
|
+
Object.entries(HttpStatusCode).forEach(function (_ref) {
|
2887
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
2888
|
+
key = _ref2[0],
|
2889
|
+
value = _ref2[1];
|
2890
|
+
HttpStatusCode[value] = key;
|
2891
|
+
});
|
2892
|
+
var HttpStatusCode$1 = HttpStatusCode;
|
2893
|
+
|
2596
2894
|
/**
|
2597
2895
|
* Create an instance of Axios
|
2598
2896
|
*
|
@@ -2601,11 +2899,11 @@
|
|
2601
2899
|
* @returns {Axios} A new instance of Axios
|
2602
2900
|
*/
|
2603
2901
|
function createInstance(defaultConfig) {
|
2604
|
-
var context = new Axios(defaultConfig);
|
2605
|
-
var instance = bind(Axios.prototype.request, context);
|
2902
|
+
var context = new Axios$1(defaultConfig);
|
2903
|
+
var instance = bind(Axios$1.prototype.request, context);
|
2606
2904
|
|
2607
2905
|
// Copy axios.prototype to instance
|
2608
|
-
utils.extend(instance, Axios.prototype, context, {
|
2906
|
+
utils.extend(instance, Axios$1.prototype, context, {
|
2609
2907
|
allOwnKeys: true
|
2610
2908
|
});
|
2611
2909
|
|
@@ -2622,14 +2920,14 @@
|
|
2622
2920
|
}
|
2623
2921
|
|
2624
2922
|
// Create the default instance to be exported
|
2625
|
-
var axios = createInstance(defaults);
|
2923
|
+
var axios = createInstance(defaults$1);
|
2626
2924
|
|
2627
2925
|
// Expose Axios class to allow class inheritance
|
2628
|
-
axios.Axios = Axios;
|
2926
|
+
axios.Axios = Axios$1;
|
2629
2927
|
|
2630
2928
|
// Expose Cancel & CancelToken
|
2631
2929
|
axios.CanceledError = CanceledError;
|
2632
|
-
axios.CancelToken = CancelToken;
|
2930
|
+
axios.CancelToken = CancelToken$1;
|
2633
2931
|
axios.isCancel = isCancel;
|
2634
2932
|
axios.VERSION = VERSION;
|
2635
2933
|
axios.toFormData = toFormData;
|
@@ -2648,9 +2946,15 @@
|
|
2648
2946
|
|
2649
2947
|
// Expose isAxiosError
|
2650
2948
|
axios.isAxiosError = isAxiosError;
|
2949
|
+
|
2950
|
+
// Expose mergeConfig
|
2951
|
+
axios.mergeConfig = mergeConfig;
|
2952
|
+
axios.AxiosHeaders = AxiosHeaders$1;
|
2651
2953
|
axios.formToJSON = function (thing) {
|
2652
2954
|
return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
2653
2955
|
};
|
2956
|
+
axios.HttpStatusCode = HttpStatusCode$1;
|
2957
|
+
axios["default"] = axios;
|
2654
2958
|
|
2655
2959
|
return axios;
|
2656
2960
|
|