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/esm/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 bind(fn, thisArg) {
|
3
3
|
return function wrap() {
|
4
4
|
return fn.apply(thisArg, arguments);
|
@@ -231,7 +231,7 @@ const trim = (str) => str.trim ?
|
|
231
231
|
* @param {Function} fn The callback to invoke for each item
|
232
232
|
*
|
233
233
|
* @param {Boolean} [allOwnKeys = false]
|
234
|
-
* @returns {
|
234
|
+
* @returns {any}
|
235
235
|
*/
|
236
236
|
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
237
237
|
// Don't bother if no value provided
|
@@ -266,6 +266,28 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
266
266
|
}
|
267
267
|
}
|
268
268
|
|
269
|
+
function findKey(obj, key) {
|
270
|
+
key = key.toLowerCase();
|
271
|
+
const keys = Object.keys(obj);
|
272
|
+
let i = keys.length;
|
273
|
+
let _key;
|
274
|
+
while (i-- > 0) {
|
275
|
+
_key = keys[i];
|
276
|
+
if (key === _key.toLowerCase()) {
|
277
|
+
return _key;
|
278
|
+
}
|
279
|
+
}
|
280
|
+
return null;
|
281
|
+
}
|
282
|
+
|
283
|
+
const _global = (() => {
|
284
|
+
/*eslint no-undef:0*/
|
285
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
286
|
+
return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
|
287
|
+
})();
|
288
|
+
|
289
|
+
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
290
|
+
|
269
291
|
/**
|
270
292
|
* Accepts varargs expecting each argument to be an object, then
|
271
293
|
* immutably merges the properties of each object and returns result.
|
@@ -285,16 +307,18 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
285
307
|
* @returns {Object} Result of all merge properties
|
286
308
|
*/
|
287
309
|
function merge(/* obj1, obj2, obj3, ... */) {
|
310
|
+
const {caseless} = isContextDefined(this) && this || {};
|
288
311
|
const result = {};
|
289
312
|
const assignValue = (val, key) => {
|
290
|
-
|
291
|
-
|
313
|
+
const targetKey = caseless && findKey(result, key) || key;
|
314
|
+
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
315
|
+
result[targetKey] = merge(result[targetKey], val);
|
292
316
|
} else if (isPlainObject(val)) {
|
293
|
-
result[
|
317
|
+
result[targetKey] = merge({}, val);
|
294
318
|
} else if (isArray(val)) {
|
295
|
-
result[
|
319
|
+
result[targetKey] = val.slice();
|
296
320
|
} else {
|
297
|
-
result[
|
321
|
+
result[targetKey] = val;
|
298
322
|
}
|
299
323
|
};
|
300
324
|
|
@@ -491,7 +515,7 @@ const matchAll = (regExp, str) => {
|
|
491
515
|
const isHTMLForm = kindOfTest('HTMLFormElement');
|
492
516
|
|
493
517
|
const toCamelCase = str => {
|
494
|
-
return str.toLowerCase().replace(/[_
|
518
|
+
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
|
495
519
|
function replacer(m, p1, p2) {
|
496
520
|
return p1.toUpperCase() + p2;
|
497
521
|
}
|
@@ -530,6 +554,11 @@ const reduceDescriptors = (obj, reducer) => {
|
|
530
554
|
|
531
555
|
const freezeMethods = (obj) => {
|
532
556
|
reduceDescriptors(obj, (descriptor, name) => {
|
557
|
+
// skip restricted props in strict mode
|
558
|
+
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
559
|
+
return false;
|
560
|
+
}
|
561
|
+
|
533
562
|
const value = obj[name];
|
534
563
|
|
535
564
|
if (!isFunction(value)) return;
|
@@ -543,7 +572,7 @@ const freezeMethods = (obj) => {
|
|
543
572
|
|
544
573
|
if (!descriptor.set) {
|
545
574
|
descriptor.set = () => {
|
546
|
-
throw Error('Can not read-only method \'' + name + '\'');
|
575
|
+
throw Error('Can not rewrite read-only method \'' + name + '\'');
|
547
576
|
};
|
548
577
|
}
|
549
578
|
});
|
@@ -570,6 +599,68 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
570
599
|
return Number.isFinite(value) ? value : defaultValue;
|
571
600
|
};
|
572
601
|
|
602
|
+
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
603
|
+
|
604
|
+
const DIGIT = '0123456789';
|
605
|
+
|
606
|
+
const ALPHABET = {
|
607
|
+
DIGIT,
|
608
|
+
ALPHA,
|
609
|
+
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
610
|
+
};
|
611
|
+
|
612
|
+
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
613
|
+
let str = '';
|
614
|
+
const {length} = alphabet;
|
615
|
+
while (size--) {
|
616
|
+
str += alphabet[Math.random() * length|0];
|
617
|
+
}
|
618
|
+
|
619
|
+
return str;
|
620
|
+
};
|
621
|
+
|
622
|
+
/**
|
623
|
+
* If the thing is a FormData object, return true, otherwise return false.
|
624
|
+
*
|
625
|
+
* @param {unknown} thing - The thing to check.
|
626
|
+
*
|
627
|
+
* @returns {boolean}
|
628
|
+
*/
|
629
|
+
function isSpecCompliantForm(thing) {
|
630
|
+
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
631
|
+
}
|
632
|
+
|
633
|
+
const toJSONObject = (obj) => {
|
634
|
+
const stack = new Array(10);
|
635
|
+
|
636
|
+
const visit = (source, i) => {
|
637
|
+
|
638
|
+
if (isObject(source)) {
|
639
|
+
if (stack.indexOf(source) >= 0) {
|
640
|
+
return;
|
641
|
+
}
|
642
|
+
|
643
|
+
if(!('toJSON' in source)) {
|
644
|
+
stack[i] = source;
|
645
|
+
const target = isArray(source) ? [] : {};
|
646
|
+
|
647
|
+
forEach(source, (value, key) => {
|
648
|
+
const reducedValue = visit(value, i + 1);
|
649
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
650
|
+
});
|
651
|
+
|
652
|
+
stack[i] = undefined;
|
653
|
+
|
654
|
+
return target;
|
655
|
+
}
|
656
|
+
}
|
657
|
+
|
658
|
+
return source;
|
659
|
+
};
|
660
|
+
|
661
|
+
return visit(obj, 0);
|
662
|
+
};
|
663
|
+
|
573
664
|
const utils = {
|
574
665
|
isArray,
|
575
666
|
isArrayBuffer,
|
@@ -612,7 +703,14 @@ const utils = {
|
|
612
703
|
toObjectSet,
|
613
704
|
toCamelCase,
|
614
705
|
noop,
|
615
|
-
toFiniteNumber
|
706
|
+
toFiniteNumber,
|
707
|
+
findKey,
|
708
|
+
global: _global,
|
709
|
+
isContextDefined,
|
710
|
+
ALPHABET,
|
711
|
+
generateString,
|
712
|
+
isSpecCompliantForm,
|
713
|
+
toJSONObject
|
616
714
|
};
|
617
715
|
|
618
716
|
/**
|
@@ -626,7 +724,7 @@ const utils = {
|
|
626
724
|
*
|
627
725
|
* @returns {Error} The created error.
|
628
726
|
*/
|
629
|
-
function AxiosError(message, code, config, request, response) {
|
727
|
+
function AxiosError$1(message, code, config, request, response) {
|
630
728
|
Error.call(this);
|
631
729
|
|
632
730
|
if (Error.captureStackTrace) {
|
@@ -643,7 +741,7 @@ function AxiosError(message, code, config, request, response) {
|
|
643
741
|
response && (this.response = response);
|
644
742
|
}
|
645
743
|
|
646
|
-
utils.inherits(AxiosError, Error, {
|
744
|
+
utils.inherits(AxiosError$1, Error, {
|
647
745
|
toJSON: function toJSON() {
|
648
746
|
return {
|
649
747
|
// Standard
|
@@ -658,14 +756,14 @@ utils.inherits(AxiosError, Error, {
|
|
658
756
|
columnNumber: this.columnNumber,
|
659
757
|
stack: this.stack,
|
660
758
|
// Axios
|
661
|
-
config: this.config,
|
759
|
+
config: utils.toJSONObject(this.config),
|
662
760
|
code: this.code,
|
663
761
|
status: this.response && this.response.status ? this.response.status : null
|
664
762
|
};
|
665
763
|
}
|
666
764
|
});
|
667
765
|
|
668
|
-
const prototype$1 = AxiosError.prototype;
|
766
|
+
const prototype$1 = AxiosError$1.prototype;
|
669
767
|
const descriptors = {};
|
670
768
|
|
671
769
|
[
|
@@ -686,11 +784,11 @@ const descriptors = {};
|
|
686
784
|
descriptors[code] = {value: code};
|
687
785
|
});
|
688
786
|
|
689
|
-
Object.defineProperties(AxiosError, descriptors);
|
787
|
+
Object.defineProperties(AxiosError$1, descriptors);
|
690
788
|
Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
691
789
|
|
692
790
|
// eslint-disable-next-line func-names
|
693
|
-
AxiosError.from = (error, code, config, request, response, customProps) => {
|
791
|
+
AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
694
792
|
const axiosError = Object.create(prototype$1);
|
695
793
|
|
696
794
|
utils.toFlatObject(error, axiosError, function filter(obj) {
|
@@ -699,7 +797,7 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
699
797
|
return prop !== 'isAxiosError';
|
700
798
|
});
|
701
799
|
|
702
|
-
AxiosError.call(axiosError, error.message, code, config, request, response);
|
800
|
+
AxiosError$1.call(axiosError, error.message, code, config, request, response);
|
703
801
|
|
704
802
|
axiosError.cause = error;
|
705
803
|
|
@@ -710,8 +808,8 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
710
808
|
return axiosError;
|
711
809
|
};
|
712
810
|
|
713
|
-
|
714
|
-
|
811
|
+
// eslint-disable-next-line strict
|
812
|
+
const httpAdapter = null;
|
715
813
|
|
716
814
|
/**
|
717
815
|
* Determines if the given thing is a array or js object.
|
@@ -768,17 +866,6 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
|
768
866
|
return /^is[A-Z]/.test(prop);
|
769
867
|
});
|
770
868
|
|
771
|
-
/**
|
772
|
-
* If the thing is a FormData object, return true, otherwise return false.
|
773
|
-
*
|
774
|
-
* @param {unknown} thing - The thing to check.
|
775
|
-
*
|
776
|
-
* @returns {boolean}
|
777
|
-
*/
|
778
|
-
function isSpecCompliant(thing) {
|
779
|
-
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
780
|
-
}
|
781
|
-
|
782
869
|
/**
|
783
870
|
* Convert a data object to FormData
|
784
871
|
*
|
@@ -802,13 +889,13 @@ function isSpecCompliant(thing) {
|
|
802
889
|
*
|
803
890
|
* @returns
|
804
891
|
*/
|
805
|
-
function toFormData(obj, formData, options) {
|
892
|
+
function toFormData$1(obj, formData, options) {
|
806
893
|
if (!utils.isObject(obj)) {
|
807
894
|
throw new TypeError('target must be an object');
|
808
895
|
}
|
809
896
|
|
810
897
|
// eslint-disable-next-line no-param-reassign
|
811
|
-
formData = formData || new (
|
898
|
+
formData = formData || new (FormData)();
|
812
899
|
|
813
900
|
// eslint-disable-next-line no-param-reassign
|
814
901
|
options = utils.toFlatObject(options, {
|
@@ -826,7 +913,7 @@ function toFormData(obj, formData, options) {
|
|
826
913
|
const dots = options.dots;
|
827
914
|
const indexes = options.indexes;
|
828
915
|
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
829
|
-
const useBlob = _Blob &&
|
916
|
+
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
830
917
|
|
831
918
|
if (!utils.isFunction(visitor)) {
|
832
919
|
throw new TypeError('visitor must be a function');
|
@@ -840,7 +927,7 @@ function toFormData(obj, formData, options) {
|
|
840
927
|
}
|
841
928
|
|
842
929
|
if (!useBlob && utils.isBlob(value)) {
|
843
|
-
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
930
|
+
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
844
931
|
}
|
845
932
|
|
846
933
|
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
|
@@ -871,7 +958,7 @@ function toFormData(obj, formData, options) {
|
|
871
958
|
value = JSON.stringify(value);
|
872
959
|
} else if (
|
873
960
|
(utils.isArray(value) && isFlatArray(value)) ||
|
874
|
-
(utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
|
961
|
+
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
|
875
962
|
)) {
|
876
963
|
// eslint-disable-next-line no-param-reassign
|
877
964
|
key = removeBrackets(key);
|
@@ -969,7 +1056,7 @@ function encode$1(str) {
|
|
969
1056
|
function AxiosURLSearchParams(params, options) {
|
970
1057
|
this._pairs = [];
|
971
1058
|
|
972
|
-
params && toFormData(params, this, options);
|
1059
|
+
params && toFormData$1(params, this, options);
|
973
1060
|
}
|
974
1061
|
|
975
1062
|
const prototype = AxiosURLSearchParams.prototype;
|
@@ -1113,6 +1200,8 @@ class InterceptorManager {
|
|
1113
1200
|
}
|
1114
1201
|
}
|
1115
1202
|
|
1203
|
+
const InterceptorManager$1 = InterceptorManager;
|
1204
|
+
|
1116
1205
|
const transitionalDefaults = {
|
1117
1206
|
silentJSONParsing: true,
|
1118
1207
|
forcedJSONParsing: true,
|
@@ -1121,7 +1210,9 @@ const transitionalDefaults = {
|
|
1121
1210
|
|
1122
1211
|
const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
1123
1212
|
|
1124
|
-
const FormData$1 = FormData;
|
1213
|
+
const FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
1214
|
+
|
1215
|
+
const Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
1125
1216
|
|
1126
1217
|
/**
|
1127
1218
|
* Determine if we're running in a standard browser environment
|
@@ -1153,19 +1244,39 @@ const isStandardBrowserEnv = (() => {
|
|
1153
1244
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
1154
1245
|
})();
|
1155
1246
|
|
1247
|
+
/**
|
1248
|
+
* Determine if we're running in a standard browser webWorker environment
|
1249
|
+
*
|
1250
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
1251
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
1252
|
+
* filtered out due to its judgment standard
|
1253
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
1254
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
1255
|
+
*/
|
1256
|
+
const isStandardBrowserWebWorkerEnv = (() => {
|
1257
|
+
return (
|
1258
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
1259
|
+
// eslint-disable-next-line no-undef
|
1260
|
+
self instanceof WorkerGlobalScope &&
|
1261
|
+
typeof self.importScripts === 'function'
|
1262
|
+
);
|
1263
|
+
})();
|
1264
|
+
|
1265
|
+
|
1156
1266
|
const platform = {
|
1157
1267
|
isBrowser: true,
|
1158
1268
|
classes: {
|
1159
1269
|
URLSearchParams: URLSearchParams$1,
|
1160
1270
|
FormData: FormData$1,
|
1161
|
-
Blob
|
1271
|
+
Blob: Blob$1
|
1162
1272
|
},
|
1163
1273
|
isStandardBrowserEnv,
|
1274
|
+
isStandardBrowserWebWorkerEnv,
|
1164
1275
|
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
1165
1276
|
};
|
1166
1277
|
|
1167
1278
|
function toURLEncodedForm(data, options) {
|
1168
|
-
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
1279
|
+
return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
|
1169
1280
|
visitor: function(value, key, path, helpers) {
|
1170
1281
|
if (platform.isNode && utils.isBuffer(value)) {
|
1171
1282
|
this.append(key, value.toString('base64'));
|
@@ -1264,209 +1375,162 @@ function formDataToJSON(formData) {
|
|
1264
1375
|
return null;
|
1265
1376
|
}
|
1266
1377
|
|
1378
|
+
const DEFAULT_CONTENT_TYPE = {
|
1379
|
+
'Content-Type': undefined
|
1380
|
+
};
|
1381
|
+
|
1267
1382
|
/**
|
1268
|
-
*
|
1383
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
1384
|
+
* of the input
|
1269
1385
|
*
|
1270
|
-
* @param {
|
1271
|
-
* @param {Function}
|
1272
|
-
* @param {
|
1386
|
+
* @param {any} rawValue - The value to be stringified.
|
1387
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
1388
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
1273
1389
|
*
|
1274
|
-
* @returns {
|
1390
|
+
* @returns {string} A stringified version of the rawValue.
|
1275
1391
|
*/
|
1276
|
-
function
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
response
|
1287
|
-
));
|
1392
|
+
function stringifySafely(rawValue, parser, encoder) {
|
1393
|
+
if (utils.isString(rawValue)) {
|
1394
|
+
try {
|
1395
|
+
(parser || JSON.parse)(rawValue);
|
1396
|
+
return utils.trim(rawValue);
|
1397
|
+
} catch (e) {
|
1398
|
+
if (e.name !== 'SyntaxError') {
|
1399
|
+
throw e;
|
1400
|
+
}
|
1401
|
+
}
|
1288
1402
|
}
|
1403
|
+
|
1404
|
+
return (encoder || JSON.stringify)(rawValue);
|
1289
1405
|
}
|
1290
1406
|
|
1291
|
-
const
|
1407
|
+
const defaults = {
|
1292
1408
|
|
1293
|
-
|
1294
|
-
(function standardBrowserEnv() {
|
1295
|
-
return {
|
1296
|
-
write: function write(name, value, expires, path, domain, secure) {
|
1297
|
-
const cookie = [];
|
1298
|
-
cookie.push(name + '=' + encodeURIComponent(value));
|
1409
|
+
transitional: transitionalDefaults,
|
1299
1410
|
|
1300
|
-
|
1301
|
-
cookie.push('expires=' + new Date(expires).toGMTString());
|
1302
|
-
}
|
1411
|
+
adapter: ['xhr', 'http'],
|
1303
1412
|
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1413
|
+
transformRequest: [function transformRequest(data, headers) {
|
1414
|
+
const contentType = headers.getContentType() || '';
|
1415
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
1416
|
+
const isObjectPayload = utils.isObject(data);
|
1307
1417
|
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1418
|
+
if (isObjectPayload && utils.isHTMLForm(data)) {
|
1419
|
+
data = new FormData(data);
|
1420
|
+
}
|
1311
1421
|
|
1312
|
-
|
1313
|
-
cookie.push('secure');
|
1314
|
-
}
|
1422
|
+
const isFormData = utils.isFormData(data);
|
1315
1423
|
|
1316
|
-
|
1317
|
-
|
1424
|
+
if (isFormData) {
|
1425
|
+
if (!hasJSONContentType) {
|
1426
|
+
return data;
|
1427
|
+
}
|
1428
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
1429
|
+
}
|
1318
1430
|
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1431
|
+
if (utils.isArrayBuffer(data) ||
|
1432
|
+
utils.isBuffer(data) ||
|
1433
|
+
utils.isStream(data) ||
|
1434
|
+
utils.isFile(data) ||
|
1435
|
+
utils.isBlob(data)
|
1436
|
+
) {
|
1437
|
+
return data;
|
1438
|
+
}
|
1439
|
+
if (utils.isArrayBufferView(data)) {
|
1440
|
+
return data.buffer;
|
1441
|
+
}
|
1442
|
+
if (utils.isURLSearchParams(data)) {
|
1443
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
1444
|
+
return data.toString();
|
1445
|
+
}
|
1323
1446
|
|
1324
|
-
|
1325
|
-
|
1447
|
+
let isFileList;
|
1448
|
+
|
1449
|
+
if (isObjectPayload) {
|
1450
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
1451
|
+
return toURLEncodedForm(data, this.formSerializer).toString();
|
1326
1452
|
}
|
1327
|
-
};
|
1328
|
-
})() :
|
1329
1453
|
|
1330
|
-
|
1331
|
-
|
1332
|
-
return {
|
1333
|
-
write: function write() {},
|
1334
|
-
read: function read() { return null; },
|
1335
|
-
remove: function remove() {}
|
1336
|
-
};
|
1337
|
-
})();
|
1454
|
+
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
1455
|
+
const _FormData = this.env && this.env.FormData;
|
1338
1456
|
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
function isAbsoluteURL(url) {
|
1347
|
-
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
1348
|
-
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
1349
|
-
// by any combination of letters, digits, plus, period, or hyphen.
|
1350
|
-
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
1351
|
-
}
|
1457
|
+
return toFormData$1(
|
1458
|
+
isFileList ? {'files[]': data} : data,
|
1459
|
+
_FormData && new _FormData(),
|
1460
|
+
this.formSerializer
|
1461
|
+
);
|
1462
|
+
}
|
1463
|
+
}
|
1352
1464
|
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
* @param {string} relativeURL The relative URL
|
1358
|
-
*
|
1359
|
-
* @returns {string} The combined URL
|
1360
|
-
*/
|
1361
|
-
function combineURLs(baseURL, relativeURL) {
|
1362
|
-
return relativeURL
|
1363
|
-
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
1364
|
-
: baseURL;
|
1365
|
-
}
|
1465
|
+
if (isObjectPayload || hasJSONContentType ) {
|
1466
|
+
headers.setContentType('application/json', false);
|
1467
|
+
return stringifySafely(data);
|
1468
|
+
}
|
1366
1469
|
|
1367
|
-
|
1368
|
-
|
1369
|
-
* only when the requestedURL is not already an absolute URL.
|
1370
|
-
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
1371
|
-
*
|
1372
|
-
* @param {string} baseURL The base URL
|
1373
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
1374
|
-
*
|
1375
|
-
* @returns {string} The combined full path
|
1376
|
-
*/
|
1377
|
-
function buildFullPath(baseURL, requestedURL) {
|
1378
|
-
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
1379
|
-
return combineURLs(baseURL, requestedURL);
|
1380
|
-
}
|
1381
|
-
return requestedURL;
|
1382
|
-
}
|
1470
|
+
return data;
|
1471
|
+
}],
|
1383
1472
|
|
1384
|
-
|
1473
|
+
transformResponse: [function transformResponse(data) {
|
1474
|
+
const transitional = this.transitional || defaults.transitional;
|
1475
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
1476
|
+
const JSONRequested = this.responseType === 'json';
|
1385
1477
|
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
1390
|
-
const urlParsingNode = document.createElement('a');
|
1391
|
-
let originURL;
|
1478
|
+
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
1479
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
1480
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
1392
1481
|
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
if (msie) {
|
1403
|
-
// IE needs attribute set twice to normalize properties
|
1404
|
-
urlParsingNode.setAttribute('href', href);
|
1405
|
-
href = urlParsingNode.href;
|
1482
|
+
try {
|
1483
|
+
return JSON.parse(data);
|
1484
|
+
} catch (e) {
|
1485
|
+
if (strictJSONParsing) {
|
1486
|
+
if (e.name === 'SyntaxError') {
|
1487
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
1488
|
+
}
|
1489
|
+
throw e;
|
1490
|
+
}
|
1406
1491
|
}
|
1492
|
+
}
|
1407
1493
|
|
1408
|
-
|
1494
|
+
return data;
|
1495
|
+
}],
|
1409
1496
|
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
1416
|
-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
1417
|
-
hostname: urlParsingNode.hostname,
|
1418
|
-
port: urlParsingNode.port,
|
1419
|
-
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
1420
|
-
urlParsingNode.pathname :
|
1421
|
-
'/' + urlParsingNode.pathname
|
1422
|
-
};
|
1423
|
-
}
|
1497
|
+
/**
|
1498
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
1499
|
+
* timeout is not created.
|
1500
|
+
*/
|
1501
|
+
timeout: 0,
|
1424
1502
|
|
1425
|
-
|
1503
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
1504
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
1426
1505
|
|
1427
|
-
|
1428
|
-
|
1429
|
-
*
|
1430
|
-
* @param {String} requestURL The URL to test
|
1431
|
-
* @returns {boolean} True if URL shares the same origin, otherwise false
|
1432
|
-
*/
|
1433
|
-
return function isURLSameOrigin(requestURL) {
|
1434
|
-
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
1435
|
-
return (parsed.protocol === originURL.protocol &&
|
1436
|
-
parsed.host === originURL.host);
|
1437
|
-
};
|
1438
|
-
})() :
|
1506
|
+
maxContentLength: -1,
|
1507
|
+
maxBodyLength: -1,
|
1439
1508
|
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
};
|
1445
|
-
})();
|
1509
|
+
env: {
|
1510
|
+
FormData: platform.classes.FormData,
|
1511
|
+
Blob: platform.classes.Blob
|
1512
|
+
},
|
1446
1513
|
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
* @param {string=} message The message.
|
1451
|
-
* @param {Object=} config The config.
|
1452
|
-
* @param {Object=} request The request.
|
1453
|
-
*
|
1454
|
-
* @returns {CanceledError} The created error.
|
1455
|
-
*/
|
1456
|
-
function CanceledError(message, config, request) {
|
1457
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
1458
|
-
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
1459
|
-
this.name = 'CanceledError';
|
1460
|
-
}
|
1514
|
+
validateStatus: function validateStatus(status) {
|
1515
|
+
return status >= 200 && status < 300;
|
1516
|
+
},
|
1461
1517
|
|
1462
|
-
|
1463
|
-
|
1518
|
+
headers: {
|
1519
|
+
common: {
|
1520
|
+
'Accept': 'application/json, text/plain, */*'
|
1521
|
+
}
|
1522
|
+
}
|
1523
|
+
};
|
1524
|
+
|
1525
|
+
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
1526
|
+
defaults.headers[method] = {};
|
1464
1527
|
});
|
1465
1528
|
|
1466
|
-
function
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1529
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
1530
|
+
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
1531
|
+
});
|
1532
|
+
|
1533
|
+
const defaults$1 = defaults;
|
1470
1534
|
|
1471
1535
|
// RawAxiosHeaders whose duplicates are ignored by node
|
1472
1536
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
@@ -1521,7 +1585,6 @@ const parseHeaders = rawHeaders => {
|
|
1521
1585
|
};
|
1522
1586
|
|
1523
1587
|
const $internals = Symbol('internals');
|
1524
|
-
const $defaults = Symbol('defaults');
|
1525
1588
|
|
1526
1589
|
function normalizeHeader(header) {
|
1527
1590
|
return header && String(header).trim().toLowerCase();
|
@@ -1547,11 +1610,19 @@ function parseTokens(str) {
|
|
1547
1610
|
return tokens;
|
1548
1611
|
}
|
1549
1612
|
|
1550
|
-
function
|
1613
|
+
function isValidHeaderName(str) {
|
1614
|
+
return /^[-_a-zA-Z]+$/.test(str.trim());
|
1615
|
+
}
|
1616
|
+
|
1617
|
+
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
1551
1618
|
if (utils.isFunction(filter)) {
|
1552
1619
|
return filter.call(this, value, header);
|
1553
1620
|
}
|
1554
1621
|
|
1622
|
+
if (isHeaderNameFilter) {
|
1623
|
+
value = header;
|
1624
|
+
}
|
1625
|
+
|
1555
1626
|
if (!utils.isString(value)) return;
|
1556
1627
|
|
1557
1628
|
if (utils.isString(filter)) {
|
@@ -1583,27 +1654,12 @@ function buildAccessors(obj, header) {
|
|
1583
1654
|
});
|
1584
1655
|
}
|
1585
1656
|
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
let i = keys.length;
|
1590
|
-
let _key;
|
1591
|
-
while (i-- > 0) {
|
1592
|
-
_key = keys[i];
|
1593
|
-
if (key === _key.toLowerCase()) {
|
1594
|
-
return _key;
|
1595
|
-
}
|
1657
|
+
class AxiosHeaders$1 {
|
1658
|
+
constructor(headers) {
|
1659
|
+
headers && this.set(headers);
|
1596
1660
|
}
|
1597
|
-
return null;
|
1598
|
-
}
|
1599
|
-
|
1600
|
-
function AxiosHeaders(headers, defaults) {
|
1601
|
-
headers && this.set(headers);
|
1602
|
-
this[$defaults] = defaults || null;
|
1603
|
-
}
|
1604
1661
|
|
1605
|
-
|
1606
|
-
set: function(header, valueOrRewrite, rewrite) {
|
1662
|
+
set(header, valueOrRewrite, rewrite) {
|
1607
1663
|
const self = this;
|
1608
1664
|
|
1609
1665
|
function setHeader(_value, _header, _rewrite) {
|
@@ -1613,69 +1669,70 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1613
1669
|
throw new Error('header name must be a non-empty string');
|
1614
1670
|
}
|
1615
1671
|
|
1616
|
-
const key = findKey(self, lHeader);
|
1672
|
+
const key = utils.findKey(self, lHeader);
|
1617
1673
|
|
1618
|
-
if
|
1619
|
-
|
1674
|
+
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
1675
|
+
self[key || _header] = normalizeValue(_value);
|
1620
1676
|
}
|
1621
|
-
|
1622
|
-
self[key || _header] = normalizeValue(_value);
|
1623
1677
|
}
|
1624
1678
|
|
1625
|
-
|
1626
|
-
utils.forEach(
|
1627
|
-
|
1628
|
-
|
1679
|
+
const setHeaders = (headers, _rewrite) =>
|
1680
|
+
utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
1681
|
+
|
1682
|
+
if (utils.isPlainObject(header) || header instanceof this.constructor) {
|
1683
|
+
setHeaders(header, valueOrRewrite);
|
1684
|
+
} else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
1685
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
1629
1686
|
} else {
|
1630
|
-
setHeader(valueOrRewrite, header, rewrite);
|
1687
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
1631
1688
|
}
|
1632
1689
|
|
1633
1690
|
return this;
|
1634
|
-
}
|
1691
|
+
}
|
1635
1692
|
|
1636
|
-
get
|
1693
|
+
get(header, parser) {
|
1637
1694
|
header = normalizeHeader(header);
|
1638
1695
|
|
1639
|
-
if (
|
1696
|
+
if (header) {
|
1697
|
+
const key = utils.findKey(this, header);
|
1640
1698
|
|
1641
|
-
|
1699
|
+
if (key) {
|
1700
|
+
const value = this[key];
|
1642
1701
|
|
1643
|
-
|
1644
|
-
|
1702
|
+
if (!parser) {
|
1703
|
+
return value;
|
1704
|
+
}
|
1645
1705
|
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1706
|
+
if (parser === true) {
|
1707
|
+
return parseTokens(value);
|
1708
|
+
}
|
1649
1709
|
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1710
|
+
if (utils.isFunction(parser)) {
|
1711
|
+
return parser.call(this, value, key);
|
1712
|
+
}
|
1653
1713
|
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1714
|
+
if (utils.isRegExp(parser)) {
|
1715
|
+
return parser.exec(value);
|
1716
|
+
}
|
1657
1717
|
|
1658
|
-
|
1659
|
-
return parser.exec(value);
|
1718
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
1660
1719
|
}
|
1661
|
-
|
1662
|
-
throw new TypeError('parser must be boolean|regexp|function');
|
1663
1720
|
}
|
1664
|
-
}
|
1721
|
+
}
|
1665
1722
|
|
1666
|
-
has
|
1723
|
+
has(header, matcher) {
|
1667
1724
|
header = normalizeHeader(header);
|
1668
1725
|
|
1669
1726
|
if (header) {
|
1670
|
-
const key = findKey(this, header);
|
1727
|
+
const key = utils.findKey(this, header);
|
1671
1728
|
|
1672
|
-
return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1729
|
+
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1673
1730
|
}
|
1674
1731
|
|
1675
1732
|
return false;
|
1676
|
-
}
|
1733
|
+
}
|
1677
1734
|
|
1678
|
-
delete
|
1735
|
+
delete(header, matcher) {
|
1679
1736
|
const self = this;
|
1680
1737
|
let deleted = false;
|
1681
1738
|
|
@@ -1683,7 +1740,7 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1683
1740
|
_header = normalizeHeader(_header);
|
1684
1741
|
|
1685
1742
|
if (_header) {
|
1686
|
-
const key = findKey(self, _header);
|
1743
|
+
const key = utils.findKey(self, _header);
|
1687
1744
|
|
1688
1745
|
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
1689
1746
|
delete self[key];
|
@@ -1700,18 +1757,30 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1700
1757
|
}
|
1701
1758
|
|
1702
1759
|
return deleted;
|
1703
|
-
}
|
1760
|
+
}
|
1704
1761
|
|
1705
|
-
clear
|
1706
|
-
|
1707
|
-
|
1762
|
+
clear(matcher) {
|
1763
|
+
const keys = Object.keys(this);
|
1764
|
+
let i = keys.length;
|
1765
|
+
let deleted = false;
|
1766
|
+
|
1767
|
+
while (i--) {
|
1768
|
+
const key = keys[i];
|
1769
|
+
if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
1770
|
+
delete this[key];
|
1771
|
+
deleted = true;
|
1772
|
+
}
|
1773
|
+
}
|
1774
|
+
|
1775
|
+
return deleted;
|
1776
|
+
}
|
1708
1777
|
|
1709
|
-
normalize
|
1778
|
+
normalize(format) {
|
1710
1779
|
const self = this;
|
1711
1780
|
const headers = {};
|
1712
1781
|
|
1713
1782
|
utils.forEach(this, (value, header) => {
|
1714
|
-
const key = findKey(headers, header);
|
1783
|
+
const key = utils.findKey(headers, header);
|
1715
1784
|
|
1716
1785
|
if (key) {
|
1717
1786
|
self[key] = normalizeValue(value);
|
@@ -1731,56 +1800,306 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1731
1800
|
});
|
1732
1801
|
|
1733
1802
|
return this;
|
1734
|
-
}
|
1803
|
+
}
|
1735
1804
|
|
1736
|
-
|
1805
|
+
concat(...targets) {
|
1806
|
+
return this.constructor.concat(this, ...targets);
|
1807
|
+
}
|
1808
|
+
|
1809
|
+
toJSON(asStrings) {
|
1737
1810
|
const obj = Object.create(null);
|
1738
1811
|
|
1739
|
-
utils.forEach(
|
1740
|
-
(value,
|
1741
|
-
|
1742
|
-
obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value;
|
1743
|
-
});
|
1812
|
+
utils.forEach(this, (value, header) => {
|
1813
|
+
value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
|
1814
|
+
});
|
1744
1815
|
|
1745
1816
|
return obj;
|
1746
1817
|
}
|
1747
|
-
});
|
1748
1818
|
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1819
|
+
[Symbol.iterator]() {
|
1820
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
1821
|
+
}
|
1822
|
+
|
1823
|
+
toString() {
|
1824
|
+
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
1825
|
+
}
|
1826
|
+
|
1827
|
+
get [Symbol.toStringTag]() {
|
1828
|
+
return 'AxiosHeaders';
|
1829
|
+
}
|
1830
|
+
|
1831
|
+
static from(thing) {
|
1754
1832
|
return thing instanceof this ? thing : new this(thing);
|
1755
|
-
}
|
1833
|
+
}
|
1834
|
+
|
1835
|
+
static concat(first, ...targets) {
|
1836
|
+
const computed = new this(first);
|
1837
|
+
|
1838
|
+
targets.forEach((target) => computed.set(target));
|
1839
|
+
|
1840
|
+
return computed;
|
1841
|
+
}
|
1756
1842
|
|
1757
|
-
accessor
|
1843
|
+
static accessor(header) {
|
1758
1844
|
const internals = this[$internals] = (this[$internals] = {
|
1759
1845
|
accessors: {}
|
1760
1846
|
});
|
1761
1847
|
|
1762
|
-
const accessors = internals.accessors;
|
1763
|
-
const prototype = this.prototype;
|
1848
|
+
const accessors = internals.accessors;
|
1849
|
+
const prototype = this.prototype;
|
1850
|
+
|
1851
|
+
function defineAccessor(_header) {
|
1852
|
+
const lHeader = normalizeHeader(_header);
|
1853
|
+
|
1854
|
+
if (!accessors[lHeader]) {
|
1855
|
+
buildAccessors(prototype, _header);
|
1856
|
+
accessors[lHeader] = true;
|
1857
|
+
}
|
1858
|
+
}
|
1859
|
+
|
1860
|
+
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
1861
|
+
|
1862
|
+
return this;
|
1863
|
+
}
|
1864
|
+
}
|
1865
|
+
|
1866
|
+
AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
1867
|
+
|
1868
|
+
utils.freezeMethods(AxiosHeaders$1.prototype);
|
1869
|
+
utils.freezeMethods(AxiosHeaders$1);
|
1870
|
+
|
1871
|
+
const AxiosHeaders$2 = AxiosHeaders$1;
|
1872
|
+
|
1873
|
+
/**
|
1874
|
+
* Transform the data for a request or a response
|
1875
|
+
*
|
1876
|
+
* @param {Array|Function} fns A single function or Array of functions
|
1877
|
+
* @param {?Object} response The response object
|
1878
|
+
*
|
1879
|
+
* @returns {*} The resulting transformed data
|
1880
|
+
*/
|
1881
|
+
function transformData(fns, response) {
|
1882
|
+
const config = this || defaults$1;
|
1883
|
+
const context = response || config;
|
1884
|
+
const headers = AxiosHeaders$2.from(context.headers);
|
1885
|
+
let data = context.data;
|
1886
|
+
|
1887
|
+
utils.forEach(fns, function transform(fn) {
|
1888
|
+
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
1889
|
+
});
|
1890
|
+
|
1891
|
+
headers.normalize();
|
1892
|
+
|
1893
|
+
return data;
|
1894
|
+
}
|
1895
|
+
|
1896
|
+
function isCancel$1(value) {
|
1897
|
+
return !!(value && value.__CANCEL__);
|
1898
|
+
}
|
1899
|
+
|
1900
|
+
/**
|
1901
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
1902
|
+
*
|
1903
|
+
* @param {string=} message The message.
|
1904
|
+
* @param {Object=} config The config.
|
1905
|
+
* @param {Object=} request The request.
|
1906
|
+
*
|
1907
|
+
* @returns {CanceledError} The created error.
|
1908
|
+
*/
|
1909
|
+
function CanceledError$1(message, config, request) {
|
1910
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
1911
|
+
AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
1912
|
+
this.name = 'CanceledError';
|
1913
|
+
}
|
1914
|
+
|
1915
|
+
utils.inherits(CanceledError$1, AxiosError$1, {
|
1916
|
+
__CANCEL__: true
|
1917
|
+
});
|
1918
|
+
|
1919
|
+
/**
|
1920
|
+
* Resolve or reject a Promise based on response status.
|
1921
|
+
*
|
1922
|
+
* @param {Function} resolve A function that resolves the promise.
|
1923
|
+
* @param {Function} reject A function that rejects the promise.
|
1924
|
+
* @param {object} response The response.
|
1925
|
+
*
|
1926
|
+
* @returns {object} The response.
|
1927
|
+
*/
|
1928
|
+
function settle(resolve, reject, response) {
|
1929
|
+
const validateStatus = response.config.validateStatus;
|
1930
|
+
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
1931
|
+
resolve(response);
|
1932
|
+
} else {
|
1933
|
+
reject(new AxiosError$1(
|
1934
|
+
'Request failed with status code ' + response.status,
|
1935
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
1936
|
+
response.config,
|
1937
|
+
response.request,
|
1938
|
+
response
|
1939
|
+
));
|
1940
|
+
}
|
1941
|
+
}
|
1942
|
+
|
1943
|
+
const cookies = platform.isStandardBrowserEnv ?
|
1944
|
+
|
1945
|
+
// Standard browser envs support document.cookie
|
1946
|
+
(function standardBrowserEnv() {
|
1947
|
+
return {
|
1948
|
+
write: function write(name, value, expires, path, domain, secure) {
|
1949
|
+
const cookie = [];
|
1950
|
+
cookie.push(name + '=' + encodeURIComponent(value));
|
1951
|
+
|
1952
|
+
if (utils.isNumber(expires)) {
|
1953
|
+
cookie.push('expires=' + new Date(expires).toGMTString());
|
1954
|
+
}
|
1955
|
+
|
1956
|
+
if (utils.isString(path)) {
|
1957
|
+
cookie.push('path=' + path);
|
1958
|
+
}
|
1959
|
+
|
1960
|
+
if (utils.isString(domain)) {
|
1961
|
+
cookie.push('domain=' + domain);
|
1962
|
+
}
|
1963
|
+
|
1964
|
+
if (secure === true) {
|
1965
|
+
cookie.push('secure');
|
1966
|
+
}
|
1967
|
+
|
1968
|
+
document.cookie = cookie.join('; ');
|
1969
|
+
},
|
1970
|
+
|
1971
|
+
read: function read(name) {
|
1972
|
+
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
1973
|
+
return (match ? decodeURIComponent(match[3]) : null);
|
1974
|
+
},
|
1975
|
+
|
1976
|
+
remove: function remove(name) {
|
1977
|
+
this.write(name, '', Date.now() - 86400000);
|
1978
|
+
}
|
1979
|
+
};
|
1980
|
+
})() :
|
1981
|
+
|
1982
|
+
// Non standard browser env (web workers, react-native) lack needed support.
|
1983
|
+
(function nonStandardBrowserEnv() {
|
1984
|
+
return {
|
1985
|
+
write: function write() {},
|
1986
|
+
read: function read() { return null; },
|
1987
|
+
remove: function remove() {}
|
1988
|
+
};
|
1989
|
+
})();
|
1990
|
+
|
1991
|
+
/**
|
1992
|
+
* Determines whether the specified URL is absolute
|
1993
|
+
*
|
1994
|
+
* @param {string} url The URL to test
|
1995
|
+
*
|
1996
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
1997
|
+
*/
|
1998
|
+
function isAbsoluteURL(url) {
|
1999
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
2000
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
2001
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
2002
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
2003
|
+
}
|
2004
|
+
|
2005
|
+
/**
|
2006
|
+
* Creates a new URL by combining the specified URLs
|
2007
|
+
*
|
2008
|
+
* @param {string} baseURL The base URL
|
2009
|
+
* @param {string} relativeURL The relative URL
|
2010
|
+
*
|
2011
|
+
* @returns {string} The combined URL
|
2012
|
+
*/
|
2013
|
+
function combineURLs(baseURL, relativeURL) {
|
2014
|
+
return relativeURL
|
2015
|
+
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
2016
|
+
: baseURL;
|
2017
|
+
}
|
2018
|
+
|
2019
|
+
/**
|
2020
|
+
* Creates a new URL by combining the baseURL with the requestedURL,
|
2021
|
+
* only when the requestedURL is not already an absolute URL.
|
2022
|
+
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
2023
|
+
*
|
2024
|
+
* @param {string} baseURL The base URL
|
2025
|
+
* @param {string} requestedURL Absolute or relative URL to combine
|
2026
|
+
*
|
2027
|
+
* @returns {string} The combined full path
|
2028
|
+
*/
|
2029
|
+
function buildFullPath(baseURL, requestedURL) {
|
2030
|
+
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
2031
|
+
return combineURLs(baseURL, requestedURL);
|
2032
|
+
}
|
2033
|
+
return requestedURL;
|
2034
|
+
}
|
2035
|
+
|
2036
|
+
const isURLSameOrigin = platform.isStandardBrowserEnv ?
|
2037
|
+
|
2038
|
+
// Standard browser envs have full support of the APIs needed to test
|
2039
|
+
// whether the request URL is of the same origin as current location.
|
2040
|
+
(function standardBrowserEnv() {
|
2041
|
+
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
2042
|
+
const urlParsingNode = document.createElement('a');
|
2043
|
+
let originURL;
|
2044
|
+
|
2045
|
+
/**
|
2046
|
+
* Parse a URL to discover it's components
|
2047
|
+
*
|
2048
|
+
* @param {String} url The URL to be parsed
|
2049
|
+
* @returns {Object}
|
2050
|
+
*/
|
2051
|
+
function resolveURL(url) {
|
2052
|
+
let href = url;
|
2053
|
+
|
2054
|
+
if (msie) {
|
2055
|
+
// IE needs attribute set twice to normalize properties
|
2056
|
+
urlParsingNode.setAttribute('href', href);
|
2057
|
+
href = urlParsingNode.href;
|
2058
|
+
}
|
1764
2059
|
|
1765
|
-
|
1766
|
-
const lHeader = normalizeHeader(_header);
|
2060
|
+
urlParsingNode.setAttribute('href', href);
|
1767
2061
|
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
2062
|
+
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
2063
|
+
return {
|
2064
|
+
href: urlParsingNode.href,
|
2065
|
+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
2066
|
+
host: urlParsingNode.host,
|
2067
|
+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
2068
|
+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
2069
|
+
hostname: urlParsingNode.hostname,
|
2070
|
+
port: urlParsingNode.port,
|
2071
|
+
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
2072
|
+
urlParsingNode.pathname :
|
2073
|
+
'/' + urlParsingNode.pathname
|
2074
|
+
};
|
1772
2075
|
}
|
1773
2076
|
|
1774
|
-
|
2077
|
+
originURL = resolveURL(window.location.href);
|
1775
2078
|
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
2079
|
+
/**
|
2080
|
+
* Determine if a URL shares the same origin as the current location
|
2081
|
+
*
|
2082
|
+
* @param {String} requestURL The URL to test
|
2083
|
+
* @returns {boolean} True if URL shares the same origin, otherwise false
|
2084
|
+
*/
|
2085
|
+
return function isURLSameOrigin(requestURL) {
|
2086
|
+
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
2087
|
+
return (parsed.protocol === originURL.protocol &&
|
2088
|
+
parsed.host === originURL.host);
|
2089
|
+
};
|
2090
|
+
})() :
|
1779
2091
|
|
1780
|
-
|
2092
|
+
// Non standard browser envs (web workers, react-native) lack needed support.
|
2093
|
+
(function nonStandardBrowserEnv() {
|
2094
|
+
return function isURLSameOrigin() {
|
2095
|
+
return true;
|
2096
|
+
};
|
2097
|
+
})();
|
1781
2098
|
|
1782
|
-
|
1783
|
-
|
2099
|
+
function parseProtocol(url) {
|
2100
|
+
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
2101
|
+
return match && match[1] || '';
|
2102
|
+
}
|
1784
2103
|
|
1785
2104
|
/**
|
1786
2105
|
* Calculate data maxRate
|
@@ -1830,7 +2149,7 @@ function speedometer(samplesCount, min) {
|
|
1830
2149
|
|
1831
2150
|
const passed = startedAt && now - startedAt;
|
1832
2151
|
|
1833
|
-
return
|
2152
|
+
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
1834
2153
|
};
|
1835
2154
|
}
|
1836
2155
|
|
@@ -1853,7 +2172,8 @@ function progressEventReducer(listener, isDownloadStream) {
|
|
1853
2172
|
progress: total ? (loaded / total) : undefined,
|
1854
2173
|
bytes: progressBytes,
|
1855
2174
|
rate: rate ? rate : undefined,
|
1856
|
-
estimated: rate && total && inRange ? (total - loaded) / rate : undefined
|
2175
|
+
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
2176
|
+
event: e
|
1857
2177
|
};
|
1858
2178
|
|
1859
2179
|
data[isDownloadStream ? 'download' : 'upload'] = true;
|
@@ -1862,10 +2182,12 @@ function progressEventReducer(listener, isDownloadStream) {
|
|
1862
2182
|
};
|
1863
2183
|
}
|
1864
2184
|
|
1865
|
-
|
2185
|
+
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
2186
|
+
|
2187
|
+
const xhrAdapter = isXHRAdapterSupported && function (config) {
|
1866
2188
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
1867
2189
|
let requestData = config.data;
|
1868
|
-
const requestHeaders = AxiosHeaders.from(config.headers).normalize();
|
2190
|
+
const requestHeaders = AxiosHeaders$2.from(config.headers).normalize();
|
1869
2191
|
const responseType = config.responseType;
|
1870
2192
|
let onCanceled;
|
1871
2193
|
function done() {
|
@@ -1878,7 +2200,7 @@ function xhrAdapter(config) {
|
|
1878
2200
|
}
|
1879
2201
|
}
|
1880
2202
|
|
1881
|
-
if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
|
2203
|
+
if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
|
1882
2204
|
requestHeaders.setContentType(false); // Let the browser set it
|
1883
2205
|
}
|
1884
2206
|
|
@@ -1903,10 +2225,10 @@ function xhrAdapter(config) {
|
|
1903
2225
|
return;
|
1904
2226
|
}
|
1905
2227
|
// Prepare the response
|
1906
|
-
const responseHeaders = AxiosHeaders.from(
|
2228
|
+
const responseHeaders = AxiosHeaders$2.from(
|
1907
2229
|
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
1908
2230
|
);
|
1909
|
-
const responseData = !responseType || responseType === 'text' ||
|
2231
|
+
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
1910
2232
|
request.responseText : request.response;
|
1911
2233
|
const response = {
|
1912
2234
|
data: responseData,
|
@@ -1958,7 +2280,7 @@ function xhrAdapter(config) {
|
|
1958
2280
|
return;
|
1959
2281
|
}
|
1960
2282
|
|
1961
|
-
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
2283
|
+
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
1962
2284
|
|
1963
2285
|
// Clean up request
|
1964
2286
|
request = null;
|
@@ -1968,7 +2290,7 @@ function xhrAdapter(config) {
|
|
1968
2290
|
request.onerror = function handleError() {
|
1969
2291
|
// Real errors are hidden from us by the browser
|
1970
2292
|
// onerror should only fire if it's a network error
|
1971
|
-
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
|
2293
|
+
reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
|
1972
2294
|
|
1973
2295
|
// Clean up request
|
1974
2296
|
request = null;
|
@@ -1981,9 +2303,9 @@ function xhrAdapter(config) {
|
|
1981
2303
|
if (config.timeoutErrorMessage) {
|
1982
2304
|
timeoutErrorMessage = config.timeoutErrorMessage;
|
1983
2305
|
}
|
1984
|
-
reject(new AxiosError(
|
2306
|
+
reject(new AxiosError$1(
|
1985
2307
|
timeoutErrorMessage,
|
1986
|
-
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
2308
|
+
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
1987
2309
|
config,
|
1988
2310
|
request));
|
1989
2311
|
|
@@ -2041,7 +2363,7 @@ function xhrAdapter(config) {
|
|
2041
2363
|
if (!request) {
|
2042
2364
|
return;
|
2043
2365
|
}
|
2044
|
-
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
2366
|
+
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
2045
2367
|
request.abort();
|
2046
2368
|
request = null;
|
2047
2369
|
};
|
@@ -2055,7 +2377,7 @@ function xhrAdapter(config) {
|
|
2055
2377
|
const protocol = parseProtocol(fullPath);
|
2056
2378
|
|
2057
2379
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
2058
|
-
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
2380
|
+
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
2059
2381
|
return;
|
2060
2382
|
}
|
2061
2383
|
|
@@ -2063,238 +2385,63 @@ function xhrAdapter(config) {
|
|
2063
2385
|
// Send the request
|
2064
2386
|
request.send(requestData || null);
|
2065
2387
|
});
|
2066
|
-
}
|
2067
|
-
|
2068
|
-
const adapters = {
|
2069
|
-
http: xhrAdapter,
|
2070
|
-
xhr: xhrAdapter
|
2071
2388
|
};
|
2072
2389
|
|
2073
|
-
const
|
2074
|
-
|
2075
|
-
|
2076
|
-
const adapter = adapters[nameOrAdapter];
|
2077
|
-
|
2078
|
-
if (!nameOrAdapter) {
|
2079
|
-
throw Error(
|
2080
|
-
utils.hasOwnProp(nameOrAdapter) ?
|
2081
|
-
`Adapter '${nameOrAdapter}' is not available in the build` :
|
2082
|
-
`Can not resolve adapter '${nameOrAdapter}'`
|
2083
|
-
);
|
2084
|
-
}
|
2085
|
-
|
2086
|
-
return adapter
|
2087
|
-
}
|
2088
|
-
|
2089
|
-
if (!utils.isFunction(nameOrAdapter)) {
|
2090
|
-
throw new TypeError('adapter is not a function');
|
2091
|
-
}
|
2092
|
-
|
2093
|
-
return nameOrAdapter;
|
2094
|
-
},
|
2095
|
-
adapters
|
2096
|
-
};
|
2097
|
-
|
2098
|
-
const DEFAULT_CONTENT_TYPE = {
|
2099
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
2390
|
+
const knownAdapters = {
|
2391
|
+
http: httpAdapter,
|
2392
|
+
xhr: xhrAdapter
|
2100
2393
|
};
|
2101
2394
|
|
2102
|
-
|
2103
|
-
|
2104
|
-
* adapter
|
2105
|
-
*
|
2106
|
-
* @returns {Function}
|
2107
|
-
*/
|
2108
|
-
function getDefaultAdapter() {
|
2109
|
-
let adapter;
|
2110
|
-
if (typeof XMLHttpRequest !== 'undefined') {
|
2111
|
-
// For browsers use XHR adapter
|
2112
|
-
adapter = adapters$1.getAdapter('xhr');
|
2113
|
-
} else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
|
2114
|
-
// For node use HTTP adapter
|
2115
|
-
adapter = adapters$1.getAdapter('http');
|
2116
|
-
}
|
2117
|
-
return adapter;
|
2118
|
-
}
|
2119
|
-
|
2120
|
-
/**
|
2121
|
-
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
2122
|
-
* of the input
|
2123
|
-
*
|
2124
|
-
* @param {any} rawValue - The value to be stringified.
|
2125
|
-
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
2126
|
-
* @param {Function} encoder - A function that takes a value and returns a string.
|
2127
|
-
*
|
2128
|
-
* @returns {string} A stringified version of the rawValue.
|
2129
|
-
*/
|
2130
|
-
function stringifySafely(rawValue, parser, encoder) {
|
2131
|
-
if (utils.isString(rawValue)) {
|
2395
|
+
utils.forEach(knownAdapters, (fn, value) => {
|
2396
|
+
if(fn) {
|
2132
2397
|
try {
|
2133
|
-
(
|
2134
|
-
return utils.trim(rawValue);
|
2398
|
+
Object.defineProperty(fn, 'name', {value});
|
2135
2399
|
} catch (e) {
|
2136
|
-
|
2137
|
-
throw e;
|
2138
|
-
}
|
2400
|
+
// eslint-disable-next-line no-empty
|
2139
2401
|
}
|
2402
|
+
Object.defineProperty(fn, 'adapterName', {value});
|
2140
2403
|
}
|
2404
|
+
});
|
2141
2405
|
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
const defaults = {
|
2146
|
-
|
2147
|
-
transitional: transitionalDefaults,
|
2148
|
-
|
2149
|
-
adapter: getDefaultAdapter(),
|
2150
|
-
|
2151
|
-
transformRequest: [function transformRequest(data, headers) {
|
2152
|
-
const contentType = headers.getContentType() || '';
|
2153
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
2154
|
-
const isObjectPayload = utils.isObject(data);
|
2155
|
-
|
2156
|
-
if (isObjectPayload && utils.isHTMLForm(data)) {
|
2157
|
-
data = new FormData(data);
|
2158
|
-
}
|
2406
|
+
const adapters = {
|
2407
|
+
getAdapter: (adapters) => {
|
2408
|
+
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
2159
2409
|
|
2160
|
-
const
|
2410
|
+
const {length} = adapters;
|
2411
|
+
let nameOrAdapter;
|
2412
|
+
let adapter;
|
2161
2413
|
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2414
|
+
for (let i = 0; i < length; i++) {
|
2415
|
+
nameOrAdapter = adapters[i];
|
2416
|
+
if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
|
2417
|
+
break;
|
2165
2418
|
}
|
2166
|
-
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
2167
|
-
}
|
2168
|
-
|
2169
|
-
if (utils.isArrayBuffer(data) ||
|
2170
|
-
utils.isBuffer(data) ||
|
2171
|
-
utils.isStream(data) ||
|
2172
|
-
utils.isFile(data) ||
|
2173
|
-
utils.isBlob(data)
|
2174
|
-
) {
|
2175
|
-
return data;
|
2176
|
-
}
|
2177
|
-
if (utils.isArrayBufferView(data)) {
|
2178
|
-
return data.buffer;
|
2179
|
-
}
|
2180
|
-
if (utils.isURLSearchParams(data)) {
|
2181
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
2182
|
-
return data.toString();
|
2183
2419
|
}
|
2184
2420
|
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
}
|
2191
|
-
|
2192
|
-
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
2193
|
-
const _FormData = this.env && this.env.FormData;
|
2194
|
-
|
2195
|
-
return toFormData(
|
2196
|
-
isFileList ? {'files[]': data} : data,
|
2197
|
-
_FormData && new _FormData(),
|
2198
|
-
this.formSerializer
|
2421
|
+
if (!adapter) {
|
2422
|
+
if (adapter === false) {
|
2423
|
+
throw new AxiosError$1(
|
2424
|
+
`Adapter ${nameOrAdapter} is not supported by the environment`,
|
2425
|
+
'ERR_NOT_SUPPORT'
|
2199
2426
|
);
|
2200
2427
|
}
|
2201
|
-
}
|
2202
2428
|
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2429
|
+
throw new Error(
|
2430
|
+
utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
|
2431
|
+
`Adapter '${nameOrAdapter}' is not available in the build` :
|
2432
|
+
`Unknown adapter '${nameOrAdapter}'`
|
2433
|
+
);
|
2206
2434
|
}
|
2207
2435
|
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
transformResponse: [function transformResponse(data) {
|
2212
|
-
const transitional = this.transitional || defaults.transitional;
|
2213
|
-
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
2214
|
-
const JSONRequested = this.responseType === 'json';
|
2215
|
-
|
2216
|
-
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
2217
|
-
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
2218
|
-
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
2219
|
-
|
2220
|
-
try {
|
2221
|
-
return JSON.parse(data);
|
2222
|
-
} catch (e) {
|
2223
|
-
if (strictJSONParsing) {
|
2224
|
-
if (e.name === 'SyntaxError') {
|
2225
|
-
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
2226
|
-
}
|
2227
|
-
throw e;
|
2228
|
-
}
|
2229
|
-
}
|
2436
|
+
if (!utils.isFunction(adapter)) {
|
2437
|
+
throw new TypeError('adapter is not a function');
|
2230
2438
|
}
|
2231
2439
|
|
2232
|
-
return
|
2233
|
-
}],
|
2234
|
-
|
2235
|
-
/**
|
2236
|
-
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
2237
|
-
* timeout is not created.
|
2238
|
-
*/
|
2239
|
-
timeout: 0,
|
2240
|
-
|
2241
|
-
xsrfCookieName: 'XSRF-TOKEN',
|
2242
|
-
xsrfHeaderName: 'X-XSRF-TOKEN',
|
2243
|
-
|
2244
|
-
maxContentLength: -1,
|
2245
|
-
maxBodyLength: -1,
|
2246
|
-
|
2247
|
-
env: {
|
2248
|
-
FormData: platform.classes.FormData,
|
2249
|
-
Blob: platform.classes.Blob
|
2250
|
-
},
|
2251
|
-
|
2252
|
-
validateStatus: function validateStatus(status) {
|
2253
|
-
return status >= 200 && status < 300;
|
2440
|
+
return adapter;
|
2254
2441
|
},
|
2255
|
-
|
2256
|
-
headers: {
|
2257
|
-
common: {
|
2258
|
-
'Accept': 'application/json, text/plain, */*'
|
2259
|
-
}
|
2260
|
-
}
|
2442
|
+
adapters: knownAdapters
|
2261
2443
|
};
|
2262
2444
|
|
2263
|
-
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
2264
|
-
defaults.headers[method] = {};
|
2265
|
-
});
|
2266
|
-
|
2267
|
-
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
2268
|
-
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
2269
|
-
});
|
2270
|
-
|
2271
|
-
/**
|
2272
|
-
* Transform the data for a request or a response
|
2273
|
-
*
|
2274
|
-
* @param {Array|Function} fns A single function or Array of functions
|
2275
|
-
* @param {?Object} response The response object
|
2276
|
-
*
|
2277
|
-
* @returns {*} The resulting transformed data
|
2278
|
-
*/
|
2279
|
-
function transformData(fns, response) {
|
2280
|
-
const config = this || defaults;
|
2281
|
-
const context = response || config;
|
2282
|
-
const headers = AxiosHeaders.from(context.headers);
|
2283
|
-
let data = context.data;
|
2284
|
-
|
2285
|
-
utils.forEach(fns, function transform(fn) {
|
2286
|
-
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
2287
|
-
});
|
2288
|
-
|
2289
|
-
headers.normalize();
|
2290
|
-
|
2291
|
-
return data;
|
2292
|
-
}
|
2293
|
-
|
2294
|
-
function isCancel(value) {
|
2295
|
-
return !!(value && value.__CANCEL__);
|
2296
|
-
}
|
2297
|
-
|
2298
2445
|
/**
|
2299
2446
|
* Throws a `CanceledError` if cancellation has been requested.
|
2300
2447
|
*
|
@@ -2308,7 +2455,7 @@ function throwIfCancellationRequested(config) {
|
|
2308
2455
|
}
|
2309
2456
|
|
2310
2457
|
if (config.signal && config.signal.aborted) {
|
2311
|
-
throw new CanceledError();
|
2458
|
+
throw new CanceledError$1(null, config);
|
2312
2459
|
}
|
2313
2460
|
}
|
2314
2461
|
|
@@ -2322,7 +2469,7 @@ function throwIfCancellationRequested(config) {
|
|
2322
2469
|
function dispatchRequest(config) {
|
2323
2470
|
throwIfCancellationRequested(config);
|
2324
2471
|
|
2325
|
-
config.headers = AxiosHeaders.from(config.headers);
|
2472
|
+
config.headers = AxiosHeaders$2.from(config.headers);
|
2326
2473
|
|
2327
2474
|
// Transform request data
|
2328
2475
|
config.data = transformData.call(
|
@@ -2330,7 +2477,11 @@ function dispatchRequest(config) {
|
|
2330
2477
|
config.transformRequest
|
2331
2478
|
);
|
2332
2479
|
|
2333
|
-
|
2480
|
+
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
2481
|
+
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
2482
|
+
}
|
2483
|
+
|
2484
|
+
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
2334
2485
|
|
2335
2486
|
return adapter(config).then(function onAdapterResolution(response) {
|
2336
2487
|
throwIfCancellationRequested(config);
|
@@ -2342,11 +2493,11 @@ function dispatchRequest(config) {
|
|
2342
2493
|
response
|
2343
2494
|
);
|
2344
2495
|
|
2345
|
-
response.headers = AxiosHeaders.from(response.headers);
|
2496
|
+
response.headers = AxiosHeaders$2.from(response.headers);
|
2346
2497
|
|
2347
2498
|
return response;
|
2348
2499
|
}, function onAdapterRejection(reason) {
|
2349
|
-
if (!isCancel(reason)) {
|
2500
|
+
if (!isCancel$1(reason)) {
|
2350
2501
|
throwIfCancellationRequested(config);
|
2351
2502
|
|
2352
2503
|
// Transform response data
|
@@ -2356,7 +2507,7 @@ function dispatchRequest(config) {
|
|
2356
2507
|
config.transformResponse,
|
2357
2508
|
reason.response
|
2358
2509
|
);
|
2359
|
-
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
2510
|
+
reason.response.headers = AxiosHeaders$2.from(reason.response.headers);
|
2360
2511
|
}
|
2361
2512
|
}
|
2362
2513
|
|
@@ -2364,6 +2515,8 @@ function dispatchRequest(config) {
|
|
2364
2515
|
});
|
2365
2516
|
}
|
2366
2517
|
|
2518
|
+
const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? thing.toJSON() : thing;
|
2519
|
+
|
2367
2520
|
/**
|
2368
2521
|
* Config-specific merge-function which creates a new config-object
|
2369
2522
|
* by merging two configuration objects together.
|
@@ -2373,14 +2526,14 @@ function dispatchRequest(config) {
|
|
2373
2526
|
*
|
2374
2527
|
* @returns {Object} New object resulting from merging config2 to config1
|
2375
2528
|
*/
|
2376
|
-
function mergeConfig(config1, config2) {
|
2529
|
+
function mergeConfig$1(config1, config2) {
|
2377
2530
|
// eslint-disable-next-line no-param-reassign
|
2378
2531
|
config2 = config2 || {};
|
2379
2532
|
const config = {};
|
2380
2533
|
|
2381
|
-
function getMergedValue(target, source) {
|
2534
|
+
function getMergedValue(target, source, caseless) {
|
2382
2535
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
2383
|
-
return utils.merge(target, source);
|
2536
|
+
return utils.merge.call({caseless}, target, source);
|
2384
2537
|
} else if (utils.isPlainObject(source)) {
|
2385
2538
|
return utils.merge({}, source);
|
2386
2539
|
} else if (utils.isArray(source)) {
|
@@ -2390,79 +2543,80 @@ function mergeConfig(config1, config2) {
|
|
2390
2543
|
}
|
2391
2544
|
|
2392
2545
|
// eslint-disable-next-line consistent-return
|
2393
|
-
function mergeDeepProperties(
|
2394
|
-
if (!utils.isUndefined(
|
2395
|
-
return getMergedValue(
|
2396
|
-
} else if (!utils.isUndefined(
|
2397
|
-
return getMergedValue(undefined,
|
2546
|
+
function mergeDeepProperties(a, b, caseless) {
|
2547
|
+
if (!utils.isUndefined(b)) {
|
2548
|
+
return getMergedValue(a, b, caseless);
|
2549
|
+
} else if (!utils.isUndefined(a)) {
|
2550
|
+
return getMergedValue(undefined, a, caseless);
|
2398
2551
|
}
|
2399
2552
|
}
|
2400
2553
|
|
2401
2554
|
// eslint-disable-next-line consistent-return
|
2402
|
-
function valueFromConfig2(
|
2403
|
-
if (!utils.isUndefined(
|
2404
|
-
return getMergedValue(undefined,
|
2555
|
+
function valueFromConfig2(a, b) {
|
2556
|
+
if (!utils.isUndefined(b)) {
|
2557
|
+
return getMergedValue(undefined, b);
|
2405
2558
|
}
|
2406
2559
|
}
|
2407
2560
|
|
2408
2561
|
// eslint-disable-next-line consistent-return
|
2409
|
-
function defaultToConfig2(
|
2410
|
-
if (!utils.isUndefined(
|
2411
|
-
return getMergedValue(undefined,
|
2412
|
-
} else if (!utils.isUndefined(
|
2413
|
-
return getMergedValue(undefined,
|
2562
|
+
function defaultToConfig2(a, b) {
|
2563
|
+
if (!utils.isUndefined(b)) {
|
2564
|
+
return getMergedValue(undefined, b);
|
2565
|
+
} else if (!utils.isUndefined(a)) {
|
2566
|
+
return getMergedValue(undefined, a);
|
2414
2567
|
}
|
2415
2568
|
}
|
2416
2569
|
|
2417
2570
|
// eslint-disable-next-line consistent-return
|
2418
|
-
function mergeDirectKeys(prop) {
|
2571
|
+
function mergeDirectKeys(a, b, prop) {
|
2419
2572
|
if (prop in config2) {
|
2420
|
-
return getMergedValue(
|
2573
|
+
return getMergedValue(a, b);
|
2421
2574
|
} else if (prop in config1) {
|
2422
|
-
return getMergedValue(undefined,
|
2575
|
+
return getMergedValue(undefined, a);
|
2423
2576
|
}
|
2424
2577
|
}
|
2425
2578
|
|
2426
2579
|
const mergeMap = {
|
2427
|
-
|
2428
|
-
|
2429
|
-
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2580
|
+
url: valueFromConfig2,
|
2581
|
+
method: valueFromConfig2,
|
2582
|
+
data: valueFromConfig2,
|
2583
|
+
baseURL: defaultToConfig2,
|
2584
|
+
transformRequest: defaultToConfig2,
|
2585
|
+
transformResponse: defaultToConfig2,
|
2586
|
+
paramsSerializer: defaultToConfig2,
|
2587
|
+
timeout: defaultToConfig2,
|
2588
|
+
timeoutMessage: defaultToConfig2,
|
2589
|
+
withCredentials: defaultToConfig2,
|
2590
|
+
adapter: defaultToConfig2,
|
2591
|
+
responseType: defaultToConfig2,
|
2592
|
+
xsrfCookieName: defaultToConfig2,
|
2593
|
+
xsrfHeaderName: defaultToConfig2,
|
2594
|
+
onUploadProgress: defaultToConfig2,
|
2595
|
+
onDownloadProgress: defaultToConfig2,
|
2596
|
+
decompress: defaultToConfig2,
|
2597
|
+
maxContentLength: defaultToConfig2,
|
2598
|
+
maxBodyLength: defaultToConfig2,
|
2599
|
+
beforeRedirect: defaultToConfig2,
|
2600
|
+
transport: defaultToConfig2,
|
2601
|
+
httpAgent: defaultToConfig2,
|
2602
|
+
httpsAgent: defaultToConfig2,
|
2603
|
+
cancelToken: defaultToConfig2,
|
2604
|
+
socketPath: defaultToConfig2,
|
2605
|
+
responseEncoding: defaultToConfig2,
|
2606
|
+
validateStatus: mergeDirectKeys,
|
2607
|
+
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
2454
2608
|
};
|
2455
2609
|
|
2456
2610
|
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
2457
2611
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
2458
|
-
const configValue = merge(prop);
|
2612
|
+
const configValue = merge(config1[prop], config2[prop], prop);
|
2459
2613
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
2460
2614
|
});
|
2461
2615
|
|
2462
2616
|
return config;
|
2463
2617
|
}
|
2464
2618
|
|
2465
|
-
const VERSION = "1.
|
2619
|
+
const VERSION$1 = "1.3.4";
|
2466
2620
|
|
2467
2621
|
const validators$1 = {};
|
2468
2622
|
|
@@ -2486,15 +2640,15 @@ const deprecatedWarnings = {};
|
|
2486
2640
|
*/
|
2487
2641
|
validators$1.transitional = function transitional(validator, version, message) {
|
2488
2642
|
function formatMessage(opt, desc) {
|
2489
|
-
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
2643
|
+
return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
2490
2644
|
}
|
2491
2645
|
|
2492
2646
|
// eslint-disable-next-line func-names
|
2493
2647
|
return (value, opt, opts) => {
|
2494
2648
|
if (validator === false) {
|
2495
|
-
throw new AxiosError(
|
2649
|
+
throw new AxiosError$1(
|
2496
2650
|
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
2497
|
-
AxiosError.ERR_DEPRECATED
|
2651
|
+
AxiosError$1.ERR_DEPRECATED
|
2498
2652
|
);
|
2499
2653
|
}
|
2500
2654
|
|
@@ -2525,7 +2679,7 @@ validators$1.transitional = function transitional(validator, version, message) {
|
|
2525
2679
|
|
2526
2680
|
function assertOptions(options, schema, allowUnknown) {
|
2527
2681
|
if (typeof options !== 'object') {
|
2528
|
-
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
2682
|
+
throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
|
2529
2683
|
}
|
2530
2684
|
const keys = Object.keys(options);
|
2531
2685
|
let i = keys.length;
|
@@ -2536,12 +2690,12 @@ function assertOptions(options, schema, allowUnknown) {
|
|
2536
2690
|
const value = options[opt];
|
2537
2691
|
const result = value === undefined || validator(value, opt, options);
|
2538
2692
|
if (result !== true) {
|
2539
|
-
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
2693
|
+
throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
|
2540
2694
|
}
|
2541
2695
|
continue;
|
2542
2696
|
}
|
2543
2697
|
if (allowUnknown !== true) {
|
2544
|
-
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
|
2698
|
+
throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
|
2545
2699
|
}
|
2546
2700
|
}
|
2547
2701
|
}
|
@@ -2560,12 +2714,12 @@ const validators = validator.validators;
|
|
2560
2714
|
*
|
2561
2715
|
* @return {Axios} A new instance of Axios
|
2562
2716
|
*/
|
2563
|
-
class Axios {
|
2717
|
+
class Axios$1 {
|
2564
2718
|
constructor(instanceConfig) {
|
2565
2719
|
this.defaults = instanceConfig;
|
2566
2720
|
this.interceptors = {
|
2567
|
-
request: new InterceptorManager(),
|
2568
|
-
response: new InterceptorManager()
|
2721
|
+
request: new InterceptorManager$1(),
|
2722
|
+
response: new InterceptorManager$1()
|
2569
2723
|
};
|
2570
2724
|
}
|
2571
2725
|
|
@@ -2587,9 +2741,9 @@ class Axios {
|
|
2587
2741
|
config = configOrUrl || {};
|
2588
2742
|
}
|
2589
2743
|
|
2590
|
-
config = mergeConfig(this.defaults, config);
|
2744
|
+
config = mergeConfig$1(this.defaults, config);
|
2591
2745
|
|
2592
|
-
const {transitional, paramsSerializer} = config;
|
2746
|
+
const {transitional, paramsSerializer, headers} = config;
|
2593
2747
|
|
2594
2748
|
if (transitional !== undefined) {
|
2595
2749
|
validator.assertOptions(transitional, {
|
@@ -2609,20 +2763,22 @@ class Axios {
|
|
2609
2763
|
// Set config.method
|
2610
2764
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
2611
2765
|
|
2766
|
+
let contextHeaders;
|
2767
|
+
|
2612
2768
|
// Flatten headers
|
2613
|
-
|
2614
|
-
|
2615
|
-
|
2769
|
+
contextHeaders = headers && utils.merge(
|
2770
|
+
headers.common,
|
2771
|
+
headers[config.method]
|
2616
2772
|
);
|
2617
2773
|
|
2618
|
-
|
2774
|
+
contextHeaders && utils.forEach(
|
2619
2775
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
2620
|
-
|
2621
|
-
delete
|
2776
|
+
(method) => {
|
2777
|
+
delete headers[method];
|
2622
2778
|
}
|
2623
2779
|
);
|
2624
2780
|
|
2625
|
-
config.headers =
|
2781
|
+
config.headers = AxiosHeaders$2.concat(contextHeaders, headers);
|
2626
2782
|
|
2627
2783
|
// filter out skipped interceptors
|
2628
2784
|
const requestInterceptorChain = [];
|
@@ -2695,7 +2851,7 @@ class Axios {
|
|
2695
2851
|
}
|
2696
2852
|
|
2697
2853
|
getUri(config) {
|
2698
|
-
config = mergeConfig(this.defaults, config);
|
2854
|
+
config = mergeConfig$1(this.defaults, config);
|
2699
2855
|
const fullPath = buildFullPath(config.baseURL, config.url);
|
2700
2856
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
2701
2857
|
}
|
@@ -2704,8 +2860,8 @@ class Axios {
|
|
2704
2860
|
// Provide aliases for supported request methods
|
2705
2861
|
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
2706
2862
|
/*eslint func-names:0*/
|
2707
|
-
Axios.prototype[method] = function(url, config) {
|
2708
|
-
return this.request(mergeConfig(config || {}, {
|
2863
|
+
Axios$1.prototype[method] = function(url, config) {
|
2864
|
+
return this.request(mergeConfig$1(config || {}, {
|
2709
2865
|
method,
|
2710
2866
|
url,
|
2711
2867
|
data: (config || {}).data
|
@@ -2718,7 +2874,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2718
2874
|
|
2719
2875
|
function generateHTTPMethod(isForm) {
|
2720
2876
|
return function httpMethod(url, data, config) {
|
2721
|
-
return this.request(mergeConfig(config || {}, {
|
2877
|
+
return this.request(mergeConfig$1(config || {}, {
|
2722
2878
|
method,
|
2723
2879
|
headers: isForm ? {
|
2724
2880
|
'Content-Type': 'multipart/form-data'
|
@@ -2729,11 +2885,13 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2729
2885
|
};
|
2730
2886
|
}
|
2731
2887
|
|
2732
|
-
Axios.prototype[method] = generateHTTPMethod();
|
2888
|
+
Axios$1.prototype[method] = generateHTTPMethod();
|
2733
2889
|
|
2734
|
-
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
2890
|
+
Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
|
2735
2891
|
});
|
2736
2892
|
|
2893
|
+
const Axios$2 = Axios$1;
|
2894
|
+
|
2737
2895
|
/**
|
2738
2896
|
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
2739
2897
|
*
|
@@ -2741,7 +2899,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2741
2899
|
*
|
2742
2900
|
* @returns {CancelToken}
|
2743
2901
|
*/
|
2744
|
-
class CancelToken {
|
2902
|
+
class CancelToken$1 {
|
2745
2903
|
constructor(executor) {
|
2746
2904
|
if (typeof executor !== 'function') {
|
2747
2905
|
throw new TypeError('executor must be a function.');
|
@@ -2789,7 +2947,7 @@ class CancelToken {
|
|
2789
2947
|
return;
|
2790
2948
|
}
|
2791
2949
|
|
2792
|
-
token.reason = new CanceledError(message, config, request);
|
2950
|
+
token.reason = new CanceledError$1(message, config, request);
|
2793
2951
|
resolvePromise(token.reason);
|
2794
2952
|
});
|
2795
2953
|
}
|
@@ -2840,7 +2998,7 @@ class CancelToken {
|
|
2840
2998
|
*/
|
2841
2999
|
static source() {
|
2842
3000
|
let cancel;
|
2843
|
-
const token = new CancelToken(function executor(c) {
|
3001
|
+
const token = new CancelToken$1(function executor(c) {
|
2844
3002
|
cancel = c;
|
2845
3003
|
});
|
2846
3004
|
return {
|
@@ -2850,6 +3008,8 @@ class CancelToken {
|
|
2850
3008
|
}
|
2851
3009
|
}
|
2852
3010
|
|
3011
|
+
const CancelToken$2 = CancelToken$1;
|
3012
|
+
|
2853
3013
|
/**
|
2854
3014
|
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
2855
3015
|
*
|
@@ -2871,7 +3031,7 @@ class CancelToken {
|
|
2871
3031
|
*
|
2872
3032
|
* @returns {Function}
|
2873
3033
|
*/
|
2874
|
-
function spread(callback) {
|
3034
|
+
function spread$1(callback) {
|
2875
3035
|
return function wrap(arr) {
|
2876
3036
|
return callback.apply(null, arr);
|
2877
3037
|
};
|
@@ -2884,10 +3044,82 @@ function spread(callback) {
|
|
2884
3044
|
*
|
2885
3045
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
2886
3046
|
*/
|
2887
|
-
function isAxiosError(payload) {
|
3047
|
+
function isAxiosError$1(payload) {
|
2888
3048
|
return utils.isObject(payload) && (payload.isAxiosError === true);
|
2889
3049
|
}
|
2890
3050
|
|
3051
|
+
const HttpStatusCode$1 = {
|
3052
|
+
Continue: 100,
|
3053
|
+
SwitchingProtocols: 101,
|
3054
|
+
Processing: 102,
|
3055
|
+
EarlyHints: 103,
|
3056
|
+
Ok: 200,
|
3057
|
+
Created: 201,
|
3058
|
+
Accepted: 202,
|
3059
|
+
NonAuthoritativeInformation: 203,
|
3060
|
+
NoContent: 204,
|
3061
|
+
ResetContent: 205,
|
3062
|
+
PartialContent: 206,
|
3063
|
+
MultiStatus: 207,
|
3064
|
+
AlreadyReported: 208,
|
3065
|
+
ImUsed: 226,
|
3066
|
+
MultipleChoices: 300,
|
3067
|
+
MovedPermanently: 301,
|
3068
|
+
Found: 302,
|
3069
|
+
SeeOther: 303,
|
3070
|
+
NotModified: 304,
|
3071
|
+
UseProxy: 305,
|
3072
|
+
Unused: 306,
|
3073
|
+
TemporaryRedirect: 307,
|
3074
|
+
PermanentRedirect: 308,
|
3075
|
+
BadRequest: 400,
|
3076
|
+
Unauthorized: 401,
|
3077
|
+
PaymentRequired: 402,
|
3078
|
+
Forbidden: 403,
|
3079
|
+
NotFound: 404,
|
3080
|
+
MethodNotAllowed: 405,
|
3081
|
+
NotAcceptable: 406,
|
3082
|
+
ProxyAuthenticationRequired: 407,
|
3083
|
+
RequestTimeout: 408,
|
3084
|
+
Conflict: 409,
|
3085
|
+
Gone: 410,
|
3086
|
+
LengthRequired: 411,
|
3087
|
+
PreconditionFailed: 412,
|
3088
|
+
PayloadTooLarge: 413,
|
3089
|
+
UriTooLong: 414,
|
3090
|
+
UnsupportedMediaType: 415,
|
3091
|
+
RangeNotSatisfiable: 416,
|
3092
|
+
ExpectationFailed: 417,
|
3093
|
+
ImATeapot: 418,
|
3094
|
+
MisdirectedRequest: 421,
|
3095
|
+
UnprocessableEntity: 422,
|
3096
|
+
Locked: 423,
|
3097
|
+
FailedDependency: 424,
|
3098
|
+
TooEarly: 425,
|
3099
|
+
UpgradeRequired: 426,
|
3100
|
+
PreconditionRequired: 428,
|
3101
|
+
TooManyRequests: 429,
|
3102
|
+
RequestHeaderFieldsTooLarge: 431,
|
3103
|
+
UnavailableForLegalReasons: 451,
|
3104
|
+
InternalServerError: 500,
|
3105
|
+
NotImplemented: 501,
|
3106
|
+
BadGateway: 502,
|
3107
|
+
ServiceUnavailable: 503,
|
3108
|
+
GatewayTimeout: 504,
|
3109
|
+
HttpVersionNotSupported: 505,
|
3110
|
+
VariantAlsoNegotiates: 506,
|
3111
|
+
InsufficientStorage: 507,
|
3112
|
+
LoopDetected: 508,
|
3113
|
+
NotExtended: 510,
|
3114
|
+
NetworkAuthenticationRequired: 511,
|
3115
|
+
};
|
3116
|
+
|
3117
|
+
Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
|
3118
|
+
HttpStatusCode$1[value] = key;
|
3119
|
+
});
|
3120
|
+
|
3121
|
+
const HttpStatusCode$2 = HttpStatusCode$1;
|
3122
|
+
|
2891
3123
|
/**
|
2892
3124
|
* Create an instance of Axios
|
2893
3125
|
*
|
@@ -2896,38 +3128,38 @@ function isAxiosError(payload) {
|
|
2896
3128
|
* @returns {Axios} A new instance of Axios
|
2897
3129
|
*/
|
2898
3130
|
function createInstance(defaultConfig) {
|
2899
|
-
const context = new Axios(defaultConfig);
|
2900
|
-
const instance = bind(Axios.prototype.request, context);
|
3131
|
+
const context = new Axios$2(defaultConfig);
|
3132
|
+
const instance = bind(Axios$2.prototype.request, context);
|
2901
3133
|
|
2902
3134
|
// Copy axios.prototype to instance
|
2903
|
-
utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});
|
3135
|
+
utils.extend(instance, Axios$2.prototype, context, {allOwnKeys: true});
|
2904
3136
|
|
2905
3137
|
// Copy context to instance
|
2906
3138
|
utils.extend(instance, context, null, {allOwnKeys: true});
|
2907
3139
|
|
2908
3140
|
// Factory for creating new instances
|
2909
3141
|
instance.create = function create(instanceConfig) {
|
2910
|
-
return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
3142
|
+
return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
|
2911
3143
|
};
|
2912
3144
|
|
2913
3145
|
return instance;
|
2914
3146
|
}
|
2915
3147
|
|
2916
3148
|
// Create the default instance to be exported
|
2917
|
-
const axios = createInstance(defaults);
|
3149
|
+
const axios = createInstance(defaults$1);
|
2918
3150
|
|
2919
3151
|
// Expose Axios class to allow class inheritance
|
2920
|
-
axios.Axios = Axios;
|
3152
|
+
axios.Axios = Axios$2;
|
2921
3153
|
|
2922
3154
|
// Expose Cancel & CancelToken
|
2923
|
-
axios.CanceledError = CanceledError;
|
2924
|
-
axios.CancelToken = CancelToken;
|
2925
|
-
axios.isCancel = isCancel;
|
2926
|
-
axios.VERSION = VERSION;
|
2927
|
-
axios.toFormData = toFormData;
|
3155
|
+
axios.CanceledError = CanceledError$1;
|
3156
|
+
axios.CancelToken = CancelToken$2;
|
3157
|
+
axios.isCancel = isCancel$1;
|
3158
|
+
axios.VERSION = VERSION$1;
|
3159
|
+
axios.toFormData = toFormData$1;
|
2928
3160
|
|
2929
3161
|
// Expose AxiosError class
|
2930
|
-
axios.AxiosError = AxiosError;
|
3162
|
+
axios.AxiosError = AxiosError$1;
|
2931
3163
|
|
2932
3164
|
// alias for CanceledError for backward compatibility
|
2933
3165
|
axios.Cancel = axios.CanceledError;
|
@@ -2937,14 +3169,45 @@ axios.all = function all(promises) {
|
|
2937
3169
|
return Promise.all(promises);
|
2938
3170
|
};
|
2939
3171
|
|
2940
|
-
axios.spread = spread;
|
3172
|
+
axios.spread = spread$1;
|
2941
3173
|
|
2942
3174
|
// Expose isAxiosError
|
2943
|
-
axios.isAxiosError = isAxiosError;
|
2944
|
-
|
2945
|
-
|
2946
|
-
|
2947
|
-
|
2948
|
-
|
2949
|
-
|
3175
|
+
axios.isAxiosError = isAxiosError$1;
|
3176
|
+
|
3177
|
+
// Expose mergeConfig
|
3178
|
+
axios.mergeConfig = mergeConfig$1;
|
3179
|
+
|
3180
|
+
axios.AxiosHeaders = AxiosHeaders$2;
|
3181
|
+
|
3182
|
+
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
3183
|
+
|
3184
|
+
axios.HttpStatusCode = HttpStatusCode$2;
|
3185
|
+
|
3186
|
+
axios.default = axios;
|
3187
|
+
|
3188
|
+
// this module should only have a default export
|
3189
|
+
const axios$1 = axios;
|
3190
|
+
|
3191
|
+
// This module is intended to unwrap Axios default export as named.
|
3192
|
+
// Keep top-level export same with static properties
|
3193
|
+
// so that it can keep same with es module or cjs
|
3194
|
+
const {
|
3195
|
+
Axios,
|
3196
|
+
AxiosError,
|
3197
|
+
CanceledError,
|
3198
|
+
isCancel,
|
3199
|
+
CancelToken,
|
3200
|
+
VERSION,
|
3201
|
+
all,
|
3202
|
+
Cancel,
|
3203
|
+
isAxiosError,
|
3204
|
+
spread,
|
3205
|
+
toFormData,
|
3206
|
+
AxiosHeaders,
|
3207
|
+
HttpStatusCode,
|
3208
|
+
formToJSON,
|
3209
|
+
mergeConfig
|
3210
|
+
} = axios$1;
|
3211
|
+
|
3212
|
+
export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, mergeConfig, spread, toFormData };
|
2950
3213
|
//# sourceMappingURL=axios.js.map
|