axios 1.1.1 → 1.1.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 +46 -1
- package/README.md +100 -16
- package/dist/axios.js +226 -491
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/esm/axios.js +33 -25
- 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 +38 -29
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.ts +7 -2
- package/index.js +30 -0
- package/lib/adapters/http.js +7 -4
- package/lib/core/Axios.js +8 -1
- package/lib/core/AxiosHeaders.js +4 -10
- package/lib/env/data.js +1 -1
- package/lib/helpers/buildURL.js +17 -10
- package/lib/helpers/toFormData.js +2 -2
- package/package.json +3 -2
- package/rollup.config.js +1 -1
package/dist/axios.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
// Axios v1.1.
|
1
|
+
// Axios v1.1.3 Copyright (c) 2022 Matt Zabriskie and contributors
|
2
2
|
(function (global, factory) {
|
3
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(
|
4
|
-
typeof define === 'function' && define.amd ? define(
|
5
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self,
|
6
|
-
})(this, (function (
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
4
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
5
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.axios = factory());
|
6
|
+
})(this, (function () { 'use strict';
|
7
7
|
|
8
8
|
function _typeof(obj) {
|
9
9
|
"@babel/helpers - typeof";
|
@@ -14,13 +14,11 @@
|
|
14
14
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
15
15
|
}, _typeof(obj);
|
16
16
|
}
|
17
|
-
|
18
17
|
function _classCallCheck(instance, Constructor) {
|
19
18
|
if (!(instance instanceof Constructor)) {
|
20
19
|
throw new TypeError("Cannot call a class as a function");
|
21
20
|
}
|
22
21
|
}
|
23
|
-
|
24
22
|
function _defineProperties(target, props) {
|
25
23
|
for (var i = 0; i < props.length; i++) {
|
26
24
|
var descriptor = props[i];
|
@@ -30,7 +28,6 @@
|
|
30
28
|
Object.defineProperty(target, descriptor.key, descriptor);
|
31
29
|
}
|
32
30
|
}
|
33
|
-
|
34
31
|
function _createClass(Constructor, protoProps, staticProps) {
|
35
32
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
36
33
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
@@ -46,28 +43,28 @@
|
|
46
43
|
};
|
47
44
|
}
|
48
45
|
|
46
|
+
// utils is a library of generic helper functions non-specific to axios
|
47
|
+
|
49
48
|
var toString = Object.prototype.toString;
|
50
49
|
var getPrototypeOf = Object.getPrototypeOf;
|
51
|
-
|
52
50
|
var kindOf = function (cache) {
|
53
51
|
return function (thing) {
|
54
52
|
var str = toString.call(thing);
|
55
53
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
56
54
|
};
|
57
55
|
}(Object.create(null));
|
58
|
-
|
59
56
|
var kindOfTest = function kindOfTest(type) {
|
60
57
|
type = type.toLowerCase();
|
61
58
|
return function (thing) {
|
62
59
|
return kindOf(thing) === type;
|
63
60
|
};
|
64
61
|
};
|
65
|
-
|
66
62
|
var typeOfTest = function typeOfTest(type) {
|
67
63
|
return function (thing) {
|
68
64
|
return _typeof(thing) === type;
|
69
65
|
};
|
70
66
|
};
|
67
|
+
|
71
68
|
/**
|
72
69
|
* Determine if a value is an Array
|
73
70
|
*
|
@@ -75,9 +72,8 @@
|
|
75
72
|
*
|
76
73
|
* @returns {boolean} True if value is an Array, otherwise false
|
77
74
|
*/
|
78
|
-
|
79
|
-
|
80
75
|
var isArray = Array.isArray;
|
76
|
+
|
81
77
|
/**
|
82
78
|
* Determine if a value is undefined
|
83
79
|
*
|
@@ -85,8 +81,8 @@
|
|
85
81
|
*
|
86
82
|
* @returns {boolean} True if the value is undefined, otherwise false
|
87
83
|
*/
|
88
|
-
|
89
84
|
var isUndefined = typeOfTest('undefined');
|
85
|
+
|
90
86
|
/**
|
91
87
|
* Determine if a value is a Buffer
|
92
88
|
*
|
@@ -94,10 +90,10 @@
|
|
94
90
|
*
|
95
91
|
* @returns {boolean} True if value is a Buffer, otherwise false
|
96
92
|
*/
|
97
|
-
|
98
93
|
function isBuffer(val) {
|
99
94
|
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
100
95
|
}
|
96
|
+
|
101
97
|
/**
|
102
98
|
* Determine if a value is an ArrayBuffer
|
103
99
|
*
|
@@ -105,9 +101,8 @@
|
|
105
101
|
*
|
106
102
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
107
103
|
*/
|
108
|
-
|
109
|
-
|
110
104
|
var isArrayBuffer = kindOfTest('ArrayBuffer');
|
105
|
+
|
111
106
|
/**
|
112
107
|
* Determine if a value is a view on an ArrayBuffer
|
113
108
|
*
|
@@ -115,18 +110,16 @@
|
|
115
110
|
*
|
116
111
|
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
117
112
|
*/
|
118
|
-
|
119
113
|
function isArrayBufferView(val) {
|
120
114
|
var result;
|
121
|
-
|
122
115
|
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
123
116
|
result = ArrayBuffer.isView(val);
|
124
117
|
} else {
|
125
118
|
result = val && val.buffer && isArrayBuffer(val.buffer);
|
126
119
|
}
|
127
|
-
|
128
120
|
return result;
|
129
121
|
}
|
122
|
+
|
130
123
|
/**
|
131
124
|
* Determine if a value is a String
|
132
125
|
*
|
@@ -134,17 +127,16 @@
|
|
134
127
|
*
|
135
128
|
* @returns {boolean} True if value is a String, otherwise false
|
136
129
|
*/
|
137
|
-
|
138
|
-
|
139
130
|
var isString = typeOfTest('string');
|
131
|
+
|
140
132
|
/**
|
141
133
|
* Determine if a value is a Function
|
142
134
|
*
|
143
135
|
* @param {*} val The value to test
|
144
136
|
* @returns {boolean} True if value is a Function, otherwise false
|
145
137
|
*/
|
146
|
-
|
147
138
|
var isFunction = typeOfTest('function');
|
139
|
+
|
148
140
|
/**
|
149
141
|
* Determine if a value is a Number
|
150
142
|
*
|
@@ -152,8 +144,8 @@
|
|
152
144
|
*
|
153
145
|
* @returns {boolean} True if value is a Number, otherwise false
|
154
146
|
*/
|
155
|
-
|
156
147
|
var isNumber = typeOfTest('number');
|
148
|
+
|
157
149
|
/**
|
158
150
|
* Determine if a value is an Object
|
159
151
|
*
|
@@ -161,21 +153,20 @@
|
|
161
153
|
*
|
162
154
|
* @returns {boolean} True if value is an Object, otherwise false
|
163
155
|
*/
|
164
|
-
|
165
156
|
var isObject = function isObject(thing) {
|
166
157
|
return thing !== null && _typeof(thing) === 'object';
|
167
158
|
};
|
159
|
+
|
168
160
|
/**
|
169
161
|
* Determine if a value is a Boolean
|
170
162
|
*
|
171
163
|
* @param {*} thing The value to test
|
172
164
|
* @returns {boolean} True if value is a Boolean, otherwise false
|
173
165
|
*/
|
174
|
-
|
175
|
-
|
176
166
|
var isBoolean = function isBoolean(thing) {
|
177
167
|
return thing === true || thing === false;
|
178
168
|
};
|
169
|
+
|
179
170
|
/**
|
180
171
|
* Determine if a value is a plain Object
|
181
172
|
*
|
@@ -183,16 +174,14 @@
|
|
183
174
|
*
|
184
175
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
185
176
|
*/
|
186
|
-
|
187
|
-
|
188
177
|
var isPlainObject = function isPlainObject(val) {
|
189
178
|
if (kindOf(val) !== 'object') {
|
190
179
|
return false;
|
191
180
|
}
|
192
|
-
|
193
181
|
var prototype = getPrototypeOf(val);
|
194
182
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
195
183
|
};
|
184
|
+
|
196
185
|
/**
|
197
186
|
* Determine if a value is a Date
|
198
187
|
*
|
@@ -200,9 +189,8 @@
|
|
200
189
|
*
|
201
190
|
* @returns {boolean} True if value is a Date, otherwise false
|
202
191
|
*/
|
203
|
-
|
204
|
-
|
205
192
|
var isDate = kindOfTest('Date');
|
193
|
+
|
206
194
|
/**
|
207
195
|
* Determine if a value is a File
|
208
196
|
*
|
@@ -210,8 +198,8 @@
|
|
210
198
|
*
|
211
199
|
* @returns {boolean} True if value is a File, otherwise false
|
212
200
|
*/
|
213
|
-
|
214
201
|
var isFile = kindOfTest('File');
|
202
|
+
|
215
203
|
/**
|
216
204
|
* Determine if a value is a Blob
|
217
205
|
*
|
@@ -219,8 +207,8 @@
|
|
219
207
|
*
|
220
208
|
* @returns {boolean} True if value is a Blob, otherwise false
|
221
209
|
*/
|
222
|
-
|
223
210
|
var isBlob = kindOfTest('Blob');
|
211
|
+
|
224
212
|
/**
|
225
213
|
* Determine if a value is a FileList
|
226
214
|
*
|
@@ -228,8 +216,8 @@
|
|
228
216
|
*
|
229
217
|
* @returns {boolean} True if value is a File, otherwise false
|
230
218
|
*/
|
231
|
-
|
232
219
|
var isFileList = kindOfTest('FileList');
|
220
|
+
|
233
221
|
/**
|
234
222
|
* Determine if a value is a Stream
|
235
223
|
*
|
@@ -237,10 +225,10 @@
|
|
237
225
|
*
|
238
226
|
* @returns {boolean} True if value is a Stream, otherwise false
|
239
227
|
*/
|
240
|
-
|
241
228
|
var isStream = function isStream(val) {
|
242
229
|
return isObject(val) && isFunction(val.pipe);
|
243
230
|
};
|
231
|
+
|
244
232
|
/**
|
245
233
|
* Determine if a value is a FormData
|
246
234
|
*
|
@@ -248,12 +236,11 @@
|
|
248
236
|
*
|
249
237
|
* @returns {boolean} True if value is an FormData, otherwise false
|
250
238
|
*/
|
251
|
-
|
252
|
-
|
253
239
|
var isFormData = function isFormData(thing) {
|
254
240
|
var pattern = '[object FormData]';
|
255
241
|
return thing && (typeof FormData === 'function' && thing instanceof FormData || toString.call(thing) === pattern || isFunction(thing.toString) && thing.toString() === pattern);
|
256
242
|
};
|
243
|
+
|
257
244
|
/**
|
258
245
|
* Determine if a value is a URLSearchParams object
|
259
246
|
*
|
@@ -261,9 +248,8 @@
|
|
261
248
|
*
|
262
249
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
263
250
|
*/
|
264
|
-
|
265
|
-
|
266
251
|
var isURLSearchParams = kindOfTest('URLSearchParams');
|
252
|
+
|
267
253
|
/**
|
268
254
|
* Trim excess whitespace off the beginning and end of a string
|
269
255
|
*
|
@@ -271,10 +257,10 @@
|
|
271
257
|
*
|
272
258
|
* @returns {String} The String freed of excess whitespace
|
273
259
|
*/
|
274
|
-
|
275
260
|
var trim = function trim(str) {
|
276
261
|
return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
277
262
|
};
|
263
|
+
|
278
264
|
/**
|
279
265
|
* Iterate over an Array or an Object invoking a function for each item.
|
280
266
|
*
|
@@ -290,26 +276,22 @@
|
|
290
276
|
* @param {Boolean} [allOwnKeys = false]
|
291
277
|
* @returns {void}
|
292
278
|
*/
|
293
|
-
|
294
|
-
|
295
279
|
function forEach(obj, fn) {
|
296
280
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
297
|
-
|
298
|
-
|
299
|
-
|
281
|
+
_ref$allOwnKeys = _ref.allOwnKeys,
|
282
|
+
allOwnKeys = _ref$allOwnKeys === void 0 ? false : _ref$allOwnKeys;
|
300
283
|
// Don't bother if no value provided
|
301
284
|
if (obj === null || typeof obj === 'undefined') {
|
302
285
|
return;
|
303
286
|
}
|
304
|
-
|
305
287
|
var i;
|
306
|
-
var l;
|
288
|
+
var l;
|
307
289
|
|
290
|
+
// Force an array if not already something iterable
|
308
291
|
if (_typeof(obj) !== 'object') {
|
309
292
|
/*eslint no-param-reassign:0*/
|
310
293
|
obj = [obj];
|
311
294
|
}
|
312
|
-
|
313
295
|
if (isArray(obj)) {
|
314
296
|
// Iterate over array values
|
315
297
|
for (i = 0, l = obj.length; i < l; i++) {
|
@@ -320,13 +302,13 @@
|
|
320
302
|
var keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
321
303
|
var len = keys.length;
|
322
304
|
var key;
|
323
|
-
|
324
305
|
for (i = 0; i < len; i++) {
|
325
306
|
key = keys[i];
|
326
307
|
fn.call(null, obj[key], key, obj);
|
327
308
|
}
|
328
309
|
}
|
329
310
|
}
|
311
|
+
|
330
312
|
/**
|
331
313
|
* Accepts varargs expecting each argument to be an object, then
|
332
314
|
* immutably merges the properties of each object and returns result.
|
@@ -345,13 +327,9 @@
|
|
345
327
|
*
|
346
328
|
* @returns {Object} Result of all merge properties
|
347
329
|
*/
|
348
|
-
|
349
|
-
|
350
|
-
function
|
351
|
-
/* obj1, obj2, obj3, ... */
|
330
|
+
function /* obj1, obj2, obj3, ... */
|
352
331
|
merge() {
|
353
332
|
var result = {};
|
354
|
-
|
355
333
|
var assignValue = function assignValue(val, key) {
|
356
334
|
if (isPlainObject(result[key]) && isPlainObject(val)) {
|
357
335
|
result[key] = merge(result[key], val);
|
@@ -363,13 +341,12 @@
|
|
363
341
|
result[key] = val;
|
364
342
|
}
|
365
343
|
};
|
366
|
-
|
367
344
|
for (var i = 0, l = arguments.length; i < l; i++) {
|
368
345
|
arguments[i] && forEach(arguments[i], assignValue);
|
369
346
|
}
|
370
|
-
|
371
347
|
return result;
|
372
348
|
}
|
349
|
+
|
373
350
|
/**
|
374
351
|
* Extends object a by mutably adding to it the properties of object b.
|
375
352
|
*
|
@@ -380,12 +357,9 @@
|
|
380
357
|
* @param {Boolean} [allOwnKeys]
|
381
358
|
* @returns {Object} The resulting value of object a
|
382
359
|
*/
|
383
|
-
|
384
|
-
|
385
360
|
var extend = function extend(a, b, thisArg) {
|
386
361
|
var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
387
|
-
|
388
|
-
|
362
|
+
allOwnKeys = _ref2.allOwnKeys;
|
389
363
|
forEach(b, function (val, key) {
|
390
364
|
if (thisArg && isFunction(val)) {
|
391
365
|
a[key] = bind(val, thisArg);
|
@@ -397,6 +371,7 @@
|
|
397
371
|
});
|
398
372
|
return a;
|
399
373
|
};
|
374
|
+
|
400
375
|
/**
|
401
376
|
* Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
|
402
377
|
*
|
@@ -404,15 +379,13 @@
|
|
404
379
|
*
|
405
380
|
* @returns {string} content value without BOM
|
406
381
|
*/
|
407
|
-
|
408
|
-
|
409
382
|
var stripBOM = function stripBOM(content) {
|
410
383
|
if (content.charCodeAt(0) === 0xFEFF) {
|
411
384
|
content = content.slice(1);
|
412
385
|
}
|
413
|
-
|
414
386
|
return content;
|
415
387
|
};
|
388
|
+
|
416
389
|
/**
|
417
390
|
* Inherit the prototype methods from one constructor into another
|
418
391
|
* @param {function} constructor
|
@@ -422,8 +395,6 @@
|
|
422
395
|
*
|
423
396
|
* @returns {void}
|
424
397
|
*/
|
425
|
-
|
426
|
-
|
427
398
|
var inherits = function inherits(constructor, superConstructor, props, descriptors) {
|
428
399
|
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
429
400
|
constructor.prototype.constructor = constructor;
|
@@ -432,6 +403,7 @@
|
|
432
403
|
});
|
433
404
|
props && Object.assign(constructor.prototype, props);
|
434
405
|
};
|
406
|
+
|
435
407
|
/**
|
436
408
|
* Resolve object with deep prototype chain to a flat object
|
437
409
|
* @param {Object} sourceObj source object
|
@@ -441,35 +413,29 @@
|
|
441
413
|
*
|
442
414
|
* @returns {Object}
|
443
415
|
*/
|
444
|
-
|
445
|
-
|
446
416
|
var toFlatObject = function toFlatObject(sourceObj, destObj, filter, propFilter) {
|
447
417
|
var props;
|
448
418
|
var i;
|
449
419
|
var prop;
|
450
420
|
var merged = {};
|
451
|
-
destObj = destObj || {};
|
452
|
-
|
421
|
+
destObj = destObj || {};
|
422
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
453
423
|
if (sourceObj == null) return destObj;
|
454
|
-
|
455
424
|
do {
|
456
425
|
props = Object.getOwnPropertyNames(sourceObj);
|
457
426
|
i = props.length;
|
458
|
-
|
459
427
|
while (i-- > 0) {
|
460
428
|
prop = props[i];
|
461
|
-
|
462
429
|
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
463
430
|
destObj[prop] = sourceObj[prop];
|
464
431
|
merged[prop] = true;
|
465
432
|
}
|
466
433
|
}
|
467
|
-
|
468
434
|
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
469
435
|
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
470
|
-
|
471
436
|
return destObj;
|
472
437
|
};
|
438
|
+
|
473
439
|
/**
|
474
440
|
* Determines whether a string ends with the characters of a specified string
|
475
441
|
*
|
@@ -479,19 +445,16 @@
|
|
479
445
|
*
|
480
446
|
* @returns {boolean}
|
481
447
|
*/
|
482
|
-
|
483
|
-
|
484
448
|
var endsWith = function endsWith(str, searchString, position) {
|
485
449
|
str = String(str);
|
486
|
-
|
487
450
|
if (position === undefined || position > str.length) {
|
488
451
|
position = str.length;
|
489
452
|
}
|
490
|
-
|
491
453
|
position -= searchString.length;
|
492
454
|
var lastIndex = str.indexOf(searchString, position);
|
493
455
|
return lastIndex !== -1 && lastIndex === position;
|
494
456
|
};
|
457
|
+
|
495
458
|
/**
|
496
459
|
* Returns new array from array like object or null if failed
|
497
460
|
*
|
@@ -499,21 +462,18 @@
|
|
499
462
|
*
|
500
463
|
* @returns {?Array}
|
501
464
|
*/
|
502
|
-
|
503
|
-
|
504
465
|
var toArray = function toArray(thing) {
|
505
466
|
if (!thing) return null;
|
506
467
|
if (isArray(thing)) return thing;
|
507
468
|
var i = thing.length;
|
508
469
|
if (!isNumber(i)) return null;
|
509
470
|
var arr = new Array(i);
|
510
|
-
|
511
471
|
while (i-- > 0) {
|
512
472
|
arr[i] = thing[i];
|
513
473
|
}
|
514
|
-
|
515
474
|
return arr;
|
516
475
|
};
|
476
|
+
|
517
477
|
/**
|
518
478
|
* Checking if the Uint8Array exists and if it does, it returns a function that checks if the
|
519
479
|
* thing passed in is an instance of Uint8Array
|
@@ -523,14 +483,13 @@
|
|
523
483
|
* @returns {Array}
|
524
484
|
*/
|
525
485
|
// eslint-disable-next-line func-names
|
526
|
-
|
527
|
-
|
528
486
|
var isTypedArray = function (TypedArray) {
|
529
487
|
// eslint-disable-next-line func-names
|
530
488
|
return function (thing) {
|
531
489
|
return TypedArray && thing instanceof TypedArray;
|
532
490
|
};
|
533
491
|
}(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
492
|
+
|
534
493
|
/**
|
535
494
|
* For each entry in the object, call the function with the key and value.
|
536
495
|
*
|
@@ -539,18 +498,16 @@
|
|
539
498
|
*
|
540
499
|
* @returns {void}
|
541
500
|
*/
|
542
|
-
|
543
|
-
|
544
501
|
var forEachEntry = function forEachEntry(obj, fn) {
|
545
502
|
var generator = obj && obj[Symbol.iterator];
|
546
503
|
var iterator = generator.call(obj);
|
547
504
|
var result;
|
548
|
-
|
549
505
|
while ((result = iterator.next()) && !result.done) {
|
550
506
|
var pair = result.value;
|
551
507
|
fn.call(obj, pair[0], pair[1]);
|
552
508
|
}
|
553
509
|
};
|
510
|
+
|
554
511
|
/**
|
555
512
|
* It takes a regular expression and a string, and returns an array of all the matches
|
556
513
|
*
|
@@ -559,37 +516,31 @@
|
|
559
516
|
*
|
560
517
|
* @returns {Array<boolean>}
|
561
518
|
*/
|
562
|
-
|
563
|
-
|
564
519
|
var matchAll = function matchAll(regExp, str) {
|
565
520
|
var matches;
|
566
521
|
var arr = [];
|
567
|
-
|
568
522
|
while ((matches = regExp.exec(str)) !== null) {
|
569
523
|
arr.push(matches);
|
570
524
|
}
|
571
|
-
|
572
525
|
return arr;
|
573
526
|
};
|
574
|
-
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
575
|
-
|
576
527
|
|
528
|
+
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
577
529
|
var isHTMLForm = kindOfTest('HTMLFormElement');
|
578
|
-
|
579
530
|
var toCamelCase = function toCamelCase(str) {
|
580
531
|
return str.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
581
532
|
return p1.toUpperCase() + p2;
|
582
533
|
});
|
583
534
|
};
|
584
|
-
/* Creating a function that will check if an object has a property. */
|
585
|
-
|
586
535
|
|
536
|
+
/* Creating a function that will check if an object has a property. */
|
587
537
|
var hasOwnProperty = function (_ref3) {
|
588
538
|
var hasOwnProperty = _ref3.hasOwnProperty;
|
589
539
|
return function (obj, prop) {
|
590
540
|
return hasOwnProperty.call(obj, prop);
|
591
541
|
};
|
592
542
|
}(Object.prototype);
|
543
|
+
|
593
544
|
/**
|
594
545
|
* Determine if a value is a RegExp object
|
595
546
|
*
|
@@ -597,10 +548,7 @@
|
|
597
548
|
*
|
598
549
|
* @returns {boolean} True if value is a RegExp object, otherwise false
|
599
550
|
*/
|
600
|
-
|
601
|
-
|
602
551
|
var isRegExp = kindOfTest('RegExp');
|
603
|
-
|
604
552
|
var reduceDescriptors = function reduceDescriptors(obj, reducer) {
|
605
553
|
var descriptors = Object.getOwnPropertyDescriptors(obj);
|
606
554
|
var reducedDescriptors = {};
|
@@ -611,23 +559,21 @@
|
|
611
559
|
});
|
612
560
|
Object.defineProperties(obj, reducedDescriptors);
|
613
561
|
};
|
562
|
+
|
614
563
|
/**
|
615
564
|
* Makes all methods read-only
|
616
565
|
* @param {Object} obj
|
617
566
|
*/
|
618
567
|
|
619
|
-
|
620
568
|
var freezeMethods = function freezeMethods(obj) {
|
621
569
|
reduceDescriptors(obj, function (descriptor, name) {
|
622
570
|
var value = obj[name];
|
623
571
|
if (!isFunction(value)) return;
|
624
572
|
descriptor.enumerable = false;
|
625
|
-
|
626
573
|
if ('writable' in descriptor) {
|
627
574
|
descriptor.writable = false;
|
628
575
|
return;
|
629
576
|
}
|
630
|
-
|
631
577
|
if (!descriptor.set) {
|
632
578
|
descriptor.set = function () {
|
633
579
|
throw Error('Can not read-only method \'' + name + '\'');
|
@@ -635,27 +581,21 @@
|
|
635
581
|
}
|
636
582
|
});
|
637
583
|
};
|
638
|
-
|
639
584
|
var toObjectSet = function toObjectSet(arrayOrString, delimiter) {
|
640
585
|
var obj = {};
|
641
|
-
|
642
586
|
var define = function define(arr) {
|
643
587
|
arr.forEach(function (value) {
|
644
588
|
obj[value] = true;
|
645
589
|
});
|
646
590
|
};
|
647
|
-
|
648
591
|
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
649
592
|
return obj;
|
650
593
|
};
|
651
|
-
|
652
594
|
var noop = function noop() {};
|
653
|
-
|
654
595
|
var toFiniteNumber = function toFiniteNumber(value, defaultValue) {
|
655
596
|
value = +value;
|
656
597
|
return Number.isFinite(value) ? value : defaultValue;
|
657
598
|
};
|
658
|
-
|
659
599
|
var utils = {
|
660
600
|
isArray: isArray,
|
661
601
|
isArrayBuffer: isArrayBuffer,
|
@@ -713,16 +653,13 @@
|
|
713
653
|
*
|
714
654
|
* @returns {Error} The created error.
|
715
655
|
*/
|
716
|
-
|
717
656
|
function AxiosError(message, code, config, request, response) {
|
718
657
|
Error.call(this);
|
719
|
-
|
720
658
|
if (Error.captureStackTrace) {
|
721
659
|
Error.captureStackTrace(this, this.constructor);
|
722
660
|
} else {
|
723
661
|
this.stack = new Error().stack;
|
724
662
|
}
|
725
|
-
|
726
663
|
this.message = message;
|
727
664
|
this.name = 'AxiosError';
|
728
665
|
code && (this.code = code);
|
@@ -730,7 +667,6 @@
|
|
730
667
|
request && (this.request = request);
|
731
668
|
response && (this.response = response);
|
732
669
|
}
|
733
|
-
|
734
670
|
utils.inherits(AxiosError, Error, {
|
735
671
|
toJSON: function toJSON() {
|
736
672
|
return {
|
@@ -754,7 +690,8 @@
|
|
754
690
|
});
|
755
691
|
var prototype$1 = AxiosError.prototype;
|
756
692
|
var descriptors = {};
|
757
|
-
['ERR_BAD_OPTION_VALUE', 'ERR_BAD_OPTION', 'ECONNABORTED', 'ETIMEDOUT', 'ERR_NETWORK', 'ERR_FR_TOO_MANY_REDIRECTS', 'ERR_DEPRECATED', 'ERR_BAD_RESPONSE', 'ERR_BAD_REQUEST', 'ERR_CANCELED', 'ERR_NOT_SUPPORT', 'ERR_INVALID_URL'
|
693
|
+
['ERR_BAD_OPTION_VALUE', 'ERR_BAD_OPTION', 'ECONNABORTED', 'ETIMEDOUT', 'ERR_NETWORK', 'ERR_FR_TOO_MANY_REDIRECTS', 'ERR_DEPRECATED', 'ERR_BAD_RESPONSE', 'ERR_BAD_REQUEST', 'ERR_CANCELED', 'ERR_NOT_SUPPORT', 'ERR_INVALID_URL'
|
694
|
+
// eslint-disable-next-line func-names
|
758
695
|
].forEach(function (code) {
|
759
696
|
descriptors[code] = {
|
760
697
|
value: code
|
@@ -763,8 +700,9 @@
|
|
763
700
|
Object.defineProperties(AxiosError, descriptors);
|
764
701
|
Object.defineProperty(prototype$1, 'isAxiosError', {
|
765
702
|
value: true
|
766
|
-
});
|
703
|
+
});
|
767
704
|
|
705
|
+
// eslint-disable-next-line func-names
|
768
706
|
AxiosError.from = function (error, code, config, request, response, customProps) {
|
769
707
|
var axiosError = Object.create(prototype$1);
|
770
708
|
utils.toFlatObject(error, axiosError, function filter(obj) {
|
@@ -789,10 +727,10 @@
|
|
789
727
|
*
|
790
728
|
* @returns {boolean}
|
791
729
|
*/
|
792
|
-
|
793
730
|
function isVisitable(thing) {
|
794
731
|
return utils.isPlainObject(thing) || utils.isArray(thing);
|
795
732
|
}
|
733
|
+
|
796
734
|
/**
|
797
735
|
* It removes the brackets from the end of a string
|
798
736
|
*
|
@@ -800,11 +738,10 @@
|
|
800
738
|
*
|
801
739
|
* @returns {string} the key without the brackets.
|
802
740
|
*/
|
803
|
-
|
804
|
-
|
805
741
|
function removeBrackets(key) {
|
806
742
|
return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
807
743
|
}
|
744
|
+
|
808
745
|
/**
|
809
746
|
* It takes a path, a key, and a boolean, and returns a string
|
810
747
|
*
|
@@ -814,8 +751,6 @@
|
|
814
751
|
*
|
815
752
|
* @returns {string} The path to the current key.
|
816
753
|
*/
|
817
|
-
|
818
|
-
|
819
754
|
function renderKey(path, key, dots) {
|
820
755
|
if (!path) return key;
|
821
756
|
return path.concat(key).map(function each(token, i) {
|
@@ -824,6 +759,7 @@
|
|
824
759
|
return !dots && i ? '[' + token + ']' : token;
|
825
760
|
}).join(dots ? '.' : '');
|
826
761
|
}
|
762
|
+
|
827
763
|
/**
|
828
764
|
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
829
765
|
*
|
@@ -831,15 +767,13 @@
|
|
831
767
|
*
|
832
768
|
* @returns {boolean}
|
833
769
|
*/
|
834
|
-
|
835
|
-
|
836
770
|
function isFlatArray(arr) {
|
837
771
|
return utils.isArray(arr) && !arr.some(isVisitable);
|
838
772
|
}
|
839
|
-
|
840
773
|
var predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
841
774
|
return /^is[A-Z]/.test(prop);
|
842
775
|
});
|
776
|
+
|
843
777
|
/**
|
844
778
|
* If the thing is a FormData object, return true, otherwise return false.
|
845
779
|
*
|
@@ -847,10 +781,10 @@
|
|
847
781
|
*
|
848
782
|
* @returns {boolean}
|
849
783
|
*/
|
850
|
-
|
851
784
|
function isSpecCompliant(thing) {
|
852
785
|
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
853
786
|
}
|
787
|
+
|
854
788
|
/**
|
855
789
|
* Convert a data object to FormData
|
856
790
|
*
|
@@ -874,16 +808,15 @@
|
|
874
808
|
*
|
875
809
|
* @returns
|
876
810
|
*/
|
877
|
-
|
878
|
-
|
879
811
|
function toFormData(obj, formData, options) {
|
880
812
|
if (!utils.isObject(obj)) {
|
881
813
|
throw new TypeError('target must be an object');
|
882
|
-
}
|
883
|
-
|
814
|
+
}
|
884
815
|
|
885
|
-
|
816
|
+
// eslint-disable-next-line no-param-reassign
|
817
|
+
formData = formData || new (browser || FormData)();
|
886
818
|
|
819
|
+
// eslint-disable-next-line no-param-reassign
|
887
820
|
options = utils.toFlatObject(options, {
|
888
821
|
metaTokens: true,
|
889
822
|
dots: false,
|
@@ -892,37 +825,30 @@
|
|
892
825
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
893
826
|
return !utils.isUndefined(source[option]);
|
894
827
|
});
|
895
|
-
var metaTokens = options.metaTokens;
|
896
|
-
|
828
|
+
var metaTokens = options.metaTokens;
|
829
|
+
// eslint-disable-next-line no-use-before-define
|
897
830
|
var visitor = options.visitor || defaultVisitor;
|
898
831
|
var dots = options.dots;
|
899
832
|
var indexes = options.indexes;
|
900
|
-
|
901
833
|
var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
902
|
-
|
903
834
|
var useBlob = _Blob && isSpecCompliant(formData);
|
904
|
-
|
905
835
|
if (!utils.isFunction(visitor)) {
|
906
836
|
throw new TypeError('visitor must be a function');
|
907
837
|
}
|
908
|
-
|
909
838
|
function convertValue(value) {
|
910
839
|
if (value === null) return '';
|
911
|
-
|
912
840
|
if (utils.isDate(value)) {
|
913
841
|
return value.toISOString();
|
914
842
|
}
|
915
|
-
|
916
843
|
if (!useBlob && utils.isBlob(value)) {
|
917
844
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
918
845
|
}
|
919
|
-
|
920
846
|
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
|
921
847
|
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
922
848
|
}
|
923
|
-
|
924
849
|
return value;
|
925
850
|
}
|
851
|
+
|
926
852
|
/**
|
927
853
|
* Default visitor.
|
928
854
|
*
|
@@ -933,65 +859,54 @@
|
|
933
859
|
*
|
934
860
|
* @returns {boolean} return true to visit the each prop of the value recursively
|
935
861
|
*/
|
936
|
-
|
937
|
-
|
938
862
|
function defaultVisitor(value, key, path) {
|
939
863
|
var arr = value;
|
940
|
-
|
941
864
|
if (value && !path && _typeof(value) === 'object') {
|
942
865
|
if (utils.endsWith(key, '{}')) {
|
943
866
|
// eslint-disable-next-line no-param-reassign
|
944
|
-
key = metaTokens ? key : key.slice(0, -2);
|
945
|
-
|
867
|
+
key = metaTokens ? key : key.slice(0, -2);
|
868
|
+
// eslint-disable-next-line no-param-reassign
|
946
869
|
value = JSON.stringify(value);
|
947
870
|
} else if (utils.isArray(value) && isFlatArray(value) || utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
|
948
871
|
// eslint-disable-next-line no-param-reassign
|
949
872
|
key = removeBrackets(key);
|
950
873
|
arr.forEach(function each(el, index) {
|
951
|
-
!utils.isUndefined(el) && formData.append(
|
874
|
+
!(utils.isUndefined(el) || el === null) && formData.append(
|
875
|
+
// eslint-disable-next-line no-nested-ternary
|
952
876
|
indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
|
953
877
|
});
|
954
878
|
return false;
|
955
879
|
}
|
956
880
|
}
|
957
|
-
|
958
881
|
if (isVisitable(value)) {
|
959
882
|
return true;
|
960
883
|
}
|
961
|
-
|
962
884
|
formData.append(renderKey(path, key, dots), convertValue(value));
|
963
885
|
return false;
|
964
886
|
}
|
965
|
-
|
966
887
|
var stack = [];
|
967
888
|
var exposedHelpers = Object.assign(predicates, {
|
968
889
|
defaultVisitor: defaultVisitor,
|
969
890
|
convertValue: convertValue,
|
970
891
|
isVisitable: isVisitable
|
971
892
|
});
|
972
|
-
|
973
893
|
function build(value, path) {
|
974
894
|
if (utils.isUndefined(value)) return;
|
975
|
-
|
976
895
|
if (stack.indexOf(value) !== -1) {
|
977
896
|
throw Error('Circular reference detected in ' + path.join('.'));
|
978
897
|
}
|
979
|
-
|
980
898
|
stack.push(value);
|
981
899
|
utils.forEach(value, function each(el, key) {
|
982
|
-
var result = !utils.isUndefined(el) && visitor.call(formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers);
|
983
|
-
|
900
|
+
var result = !(utils.isUndefined(el) || el === null) && visitor.call(formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers);
|
984
901
|
if (result === true) {
|
985
902
|
build(el, path ? path.concat(key) : [key]);
|
986
903
|
}
|
987
904
|
});
|
988
905
|
stack.pop();
|
989
906
|
}
|
990
|
-
|
991
907
|
if (!utils.isObject(obj)) {
|
992
908
|
throw new TypeError('data must be an object');
|
993
909
|
}
|
994
|
-
|
995
910
|
build(obj);
|
996
911
|
return formData;
|
997
912
|
}
|
@@ -1004,7 +919,6 @@
|
|
1004
919
|
*
|
1005
920
|
* @returns {string} The encoded string.
|
1006
921
|
*/
|
1007
|
-
|
1008
922
|
function encode$1(str) {
|
1009
923
|
var charMap = {
|
1010
924
|
'!': '%21',
|
@@ -1019,6 +933,7 @@
|
|
1019
933
|
return charMap[match];
|
1020
934
|
});
|
1021
935
|
}
|
936
|
+
|
1022
937
|
/**
|
1023
938
|
* It takes a params object and converts it to a FormData object
|
1024
939
|
*
|
@@ -1027,24 +942,18 @@
|
|
1027
942
|
*
|
1028
943
|
* @returns {void}
|
1029
944
|
*/
|
1030
|
-
|
1031
|
-
|
1032
945
|
function AxiosURLSearchParams(params, options) {
|
1033
946
|
this._pairs = [];
|
1034
947
|
params && toFormData(params, this, options);
|
1035
948
|
}
|
1036
|
-
|
1037
949
|
var prototype = AxiosURLSearchParams.prototype;
|
1038
|
-
|
1039
950
|
prototype.append = function append(name, value) {
|
1040
951
|
this._pairs.push([name, value]);
|
1041
952
|
};
|
1042
|
-
|
1043
953
|
prototype.toString = function toString(encoder) {
|
1044
954
|
var _encode = encoder ? function (value) {
|
1045
955
|
return encoder.call(this, value, encode$1);
|
1046
956
|
} : encode$1;
|
1047
|
-
|
1048
957
|
return this._pairs.map(function each(pair) {
|
1049
958
|
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
1050
959
|
}, '').join('&');
|
@@ -1058,10 +967,10 @@
|
|
1058
967
|
*
|
1059
968
|
* @returns {string} The encoded value.
|
1060
969
|
*/
|
1061
|
-
|
1062
970
|
function encode(val) {
|
1063
971
|
return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']');
|
1064
972
|
}
|
973
|
+
|
1065
974
|
/**
|
1066
975
|
* Build a URL by appending params to the end
|
1067
976
|
*
|
@@ -1071,37 +980,35 @@
|
|
1071
980
|
*
|
1072
981
|
* @returns {string} The formatted url
|
1073
982
|
*/
|
1074
|
-
|
1075
|
-
|
1076
983
|
function buildURL(url, params, options) {
|
1077
984
|
/*eslint no-param-reassign:0*/
|
1078
985
|
if (!params) {
|
1079
986
|
return url;
|
1080
987
|
}
|
1081
|
-
|
1082
|
-
var hashmarkIndex = url.indexOf('#');
|
1083
|
-
|
1084
|
-
if (hashmarkIndex !== -1) {
|
1085
|
-
url = url.slice(0, hashmarkIndex);
|
1086
|
-
}
|
1087
|
-
|
1088
988
|
var _encode = options && options.encode || encode;
|
1089
|
-
|
1090
|
-
var
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
989
|
+
var serializeFn = options && options.serialize;
|
990
|
+
var serializedParams;
|
991
|
+
if (serializeFn) {
|
992
|
+
serializedParams = serializeFn(params, options);
|
993
|
+
} else {
|
994
|
+
serializedParams = utils.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
|
995
|
+
}
|
996
|
+
if (serializedParams) {
|
997
|
+
var hashmarkIndex = url.indexOf("#");
|
998
|
+
if (hashmarkIndex !== -1) {
|
999
|
+
url = url.slice(0, hashmarkIndex);
|
1000
|
+
}
|
1001
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
1094
1002
|
}
|
1095
|
-
|
1096
1003
|
return url;
|
1097
1004
|
}
|
1098
1005
|
|
1099
1006
|
var InterceptorManager = /*#__PURE__*/function () {
|
1100
1007
|
function InterceptorManager() {
|
1101
1008
|
_classCallCheck(this, InterceptorManager);
|
1102
|
-
|
1103
1009
|
this.handlers = [];
|
1104
1010
|
}
|
1011
|
+
|
1105
1012
|
/**
|
1106
1013
|
* Add a new interceptor to the stack
|
1107
1014
|
*
|
@@ -1110,8 +1017,6 @@
|
|
1110
1017
|
*
|
1111
1018
|
* @return {Number} An ID used to remove interceptor later
|
1112
1019
|
*/
|
1113
|
-
|
1114
|
-
|
1115
1020
|
_createClass(InterceptorManager, [{
|
1116
1021
|
key: "use",
|
1117
1022
|
value: function use(fulfilled, rejected, options) {
|
@@ -1123,6 +1028,7 @@
|
|
1123
1028
|
});
|
1124
1029
|
return this.handlers.length - 1;
|
1125
1030
|
}
|
1031
|
+
|
1126
1032
|
/**
|
1127
1033
|
* Remove an interceptor from the stack
|
1128
1034
|
*
|
@@ -1130,7 +1036,6 @@
|
|
1130
1036
|
*
|
1131
1037
|
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
1132
1038
|
*/
|
1133
|
-
|
1134
1039
|
}, {
|
1135
1040
|
key: "eject",
|
1136
1041
|
value: function eject(id) {
|
@@ -1138,12 +1043,12 @@
|
|
1138
1043
|
this.handlers[id] = null;
|
1139
1044
|
}
|
1140
1045
|
}
|
1046
|
+
|
1141
1047
|
/**
|
1142
1048
|
* Clear all interceptors from the stack
|
1143
1049
|
*
|
1144
1050
|
* @returns {void}
|
1145
1051
|
*/
|
1146
|
-
|
1147
1052
|
}, {
|
1148
1053
|
key: "clear",
|
1149
1054
|
value: function clear() {
|
@@ -1151,6 +1056,7 @@
|
|
1151
1056
|
this.handlers = [];
|
1152
1057
|
}
|
1153
1058
|
}
|
1059
|
+
|
1154
1060
|
/**
|
1155
1061
|
* Iterate over all the registered interceptors
|
1156
1062
|
*
|
@@ -1161,7 +1067,6 @@
|
|
1161
1067
|
*
|
1162
1068
|
* @returns {void}
|
1163
1069
|
*/
|
1164
|
-
|
1165
1070
|
}, {
|
1166
1071
|
key: "forEach",
|
1167
1072
|
value: function forEach(fn) {
|
@@ -1172,7 +1077,6 @@
|
|
1172
1077
|
});
|
1173
1078
|
}
|
1174
1079
|
}]);
|
1175
|
-
|
1176
1080
|
return InterceptorManager;
|
1177
1081
|
}();
|
1178
1082
|
|
@@ -1203,17 +1107,13 @@
|
|
1203
1107
|
*
|
1204
1108
|
* @returns {boolean}
|
1205
1109
|
*/
|
1206
|
-
|
1207
1110
|
var isStandardBrowserEnv = function () {
|
1208
1111
|
var product;
|
1209
|
-
|
1210
1112
|
if (typeof navigator !== 'undefined' && ((product = navigator.product) === 'ReactNative' || product === 'NativeScript' || product === 'NS')) {
|
1211
1113
|
return false;
|
1212
1114
|
}
|
1213
|
-
|
1214
1115
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
1215
1116
|
}();
|
1216
|
-
|
1217
1117
|
var platform = {
|
1218
1118
|
isBrowser: true,
|
1219
1119
|
classes: {
|
@@ -1232,7 +1132,6 @@
|
|
1232
1132
|
this.append(key, value.toString('base64'));
|
1233
1133
|
return false;
|
1234
1134
|
}
|
1235
|
-
|
1236
1135
|
return helpers.defaultVisitor.apply(this, arguments);
|
1237
1136
|
}
|
1238
1137
|
}, options));
|
@@ -1245,7 +1144,6 @@
|
|
1245
1144
|
*
|
1246
1145
|
* @returns An array of strings.
|
1247
1146
|
*/
|
1248
|
-
|
1249
1147
|
function parsePropPath(name) {
|
1250
1148
|
// foo[x][y][z]
|
1251
1149
|
// foo.x.y.z
|
@@ -1255,6 +1153,7 @@
|
|
1255
1153
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
1256
1154
|
});
|
1257
1155
|
}
|
1156
|
+
|
1258
1157
|
/**
|
1259
1158
|
* Convert an array to an object.
|
1260
1159
|
*
|
@@ -1262,22 +1161,19 @@
|
|
1262
1161
|
*
|
1263
1162
|
* @returns An object with the same keys and values as the array.
|
1264
1163
|
*/
|
1265
|
-
|
1266
|
-
|
1267
1164
|
function arrayToObject(arr) {
|
1268
1165
|
var obj = {};
|
1269
1166
|
var keys = Object.keys(arr);
|
1270
1167
|
var i;
|
1271
1168
|
var len = keys.length;
|
1272
1169
|
var key;
|
1273
|
-
|
1274
1170
|
for (i = 0; i < len; i++) {
|
1275
1171
|
key = keys[i];
|
1276
1172
|
obj[key] = arr[key];
|
1277
1173
|
}
|
1278
|
-
|
1279
1174
|
return obj;
|
1280
1175
|
}
|
1176
|
+
|
1281
1177
|
/**
|
1282
1178
|
* It takes a FormData object and returns a JavaScript object
|
1283
1179
|
*
|
@@ -1285,38 +1181,29 @@
|
|
1285
1181
|
*
|
1286
1182
|
* @returns {Object<string, any> | null} The converted object.
|
1287
1183
|
*/
|
1288
|
-
|
1289
|
-
|
1290
1184
|
function formDataToJSON(formData) {
|
1291
1185
|
function buildPath(path, value, target, index) {
|
1292
1186
|
var name = path[index++];
|
1293
1187
|
var isNumericKey = Number.isFinite(+name);
|
1294
1188
|
var isLast = index >= path.length;
|
1295
1189
|
name = !name && utils.isArray(target) ? target.length : name;
|
1296
|
-
|
1297
1190
|
if (isLast) {
|
1298
1191
|
if (utils.hasOwnProp(target, name)) {
|
1299
1192
|
target[name] = [target[name], value];
|
1300
1193
|
} else {
|
1301
1194
|
target[name] = value;
|
1302
1195
|
}
|
1303
|
-
|
1304
1196
|
return !isNumericKey;
|
1305
1197
|
}
|
1306
|
-
|
1307
1198
|
if (!target[name] || !utils.isObject(target[name])) {
|
1308
1199
|
target[name] = [];
|
1309
1200
|
}
|
1310
|
-
|
1311
1201
|
var result = buildPath(path, value, target[name], index);
|
1312
|
-
|
1313
1202
|
if (result && utils.isArray(target[name])) {
|
1314
1203
|
target[name] = arrayToObject(target[name]);
|
1315
1204
|
}
|
1316
|
-
|
1317
1205
|
return !isNumericKey;
|
1318
1206
|
}
|
1319
|
-
|
1320
1207
|
if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
|
1321
1208
|
var obj = {};
|
1322
1209
|
utils.forEachEntry(formData, function (name, value) {
|
@@ -1324,7 +1211,6 @@
|
|
1324
1211
|
});
|
1325
1212
|
return obj;
|
1326
1213
|
}
|
1327
|
-
|
1328
1214
|
return null;
|
1329
1215
|
}
|
1330
1216
|
|
@@ -1337,10 +1223,8 @@
|
|
1337
1223
|
*
|
1338
1224
|
* @returns {object} The response.
|
1339
1225
|
*/
|
1340
|
-
|
1341
1226
|
function settle(resolve, reject, response) {
|
1342
1227
|
var validateStatus = response.config.validateStatus;
|
1343
|
-
|
1344
1228
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
1345
1229
|
resolve(response);
|
1346
1230
|
} else {
|
@@ -1348,29 +1232,25 @@
|
|
1348
1232
|
}
|
1349
1233
|
}
|
1350
1234
|
|
1351
|
-
var cookies = platform.isStandardBrowserEnv ?
|
1235
|
+
var cookies = platform.isStandardBrowserEnv ?
|
1236
|
+
// Standard browser envs support document.cookie
|
1352
1237
|
function standardBrowserEnv() {
|
1353
1238
|
return {
|
1354
1239
|
write: function write(name, value, expires, path, domain, secure) {
|
1355
1240
|
var cookie = [];
|
1356
1241
|
cookie.push(name + '=' + encodeURIComponent(value));
|
1357
|
-
|
1358
1242
|
if (utils.isNumber(expires)) {
|
1359
1243
|
cookie.push('expires=' + new Date(expires).toGMTString());
|
1360
1244
|
}
|
1361
|
-
|
1362
1245
|
if (utils.isString(path)) {
|
1363
1246
|
cookie.push('path=' + path);
|
1364
1247
|
}
|
1365
|
-
|
1366
1248
|
if (utils.isString(domain)) {
|
1367
1249
|
cookie.push('domain=' + domain);
|
1368
1250
|
}
|
1369
|
-
|
1370
1251
|
if (secure === true) {
|
1371
1252
|
cookie.push('secure');
|
1372
1253
|
}
|
1373
|
-
|
1374
1254
|
document.cookie = cookie.join('; ');
|
1375
1255
|
},
|
1376
1256
|
read: function read(name) {
|
@@ -1381,7 +1261,8 @@
|
|
1381
1261
|
this.write(name, '', Date.now() - 86400000);
|
1382
1262
|
}
|
1383
1263
|
};
|
1384
|
-
}() :
|
1264
|
+
}() :
|
1265
|
+
// Non standard browser env (web workers, react-native) lack needed support.
|
1385
1266
|
function nonStandardBrowserEnv() {
|
1386
1267
|
return {
|
1387
1268
|
write: function write() {},
|
@@ -1399,7 +1280,6 @@
|
|
1399
1280
|
*
|
1400
1281
|
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
1401
1282
|
*/
|
1402
|
-
|
1403
1283
|
function isAbsoluteURL(url) {
|
1404
1284
|
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
1405
1285
|
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
@@ -1415,7 +1295,6 @@
|
|
1415
1295
|
*
|
1416
1296
|
* @returns {string} The combined URL
|
1417
1297
|
*/
|
1418
|
-
|
1419
1298
|
function combineURLs(baseURL, relativeURL) {
|
1420
1299
|
return relativeURL ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
|
1421
1300
|
}
|
@@ -1430,39 +1309,37 @@
|
|
1430
1309
|
*
|
1431
1310
|
* @returns {string} The combined full path
|
1432
1311
|
*/
|
1433
|
-
|
1434
1312
|
function buildFullPath(baseURL, requestedURL) {
|
1435
1313
|
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
1436
1314
|
return combineURLs(baseURL, requestedURL);
|
1437
1315
|
}
|
1438
|
-
|
1439
1316
|
return requestedURL;
|
1440
1317
|
}
|
1441
1318
|
|
1442
|
-
var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
1319
|
+
var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
1320
|
+
// Standard browser envs have full support of the APIs needed to test
|
1443
1321
|
// whether the request URL is of the same origin as current location.
|
1444
1322
|
function standardBrowserEnv() {
|
1445
1323
|
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
1446
1324
|
var urlParsingNode = document.createElement('a');
|
1447
1325
|
var originURL;
|
1326
|
+
|
1448
1327
|
/**
|
1449
1328
|
* Parse a URL to discover it's components
|
1450
1329
|
*
|
1451
1330
|
* @param {String} url The URL to be parsed
|
1452
1331
|
* @returns {Object}
|
1453
1332
|
*/
|
1454
|
-
|
1455
1333
|
function resolveURL(url) {
|
1456
1334
|
var href = url;
|
1457
|
-
|
1458
1335
|
if (msie) {
|
1459
1336
|
// IE needs attribute set twice to normalize properties
|
1460
1337
|
urlParsingNode.setAttribute('href', href);
|
1461
1338
|
href = urlParsingNode.href;
|
1462
1339
|
}
|
1340
|
+
urlParsingNode.setAttribute('href', href);
|
1463
1341
|
|
1464
|
-
|
1465
|
-
|
1342
|
+
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
1466
1343
|
return {
|
1467
1344
|
href: urlParsingNode.href,
|
1468
1345
|
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
@@ -1474,20 +1351,20 @@
|
|
1474
1351
|
pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname
|
1475
1352
|
};
|
1476
1353
|
}
|
1477
|
-
|
1478
1354
|
originURL = resolveURL(window.location.href);
|
1355
|
+
|
1479
1356
|
/**
|
1480
1357
|
* Determine if a URL shares the same origin as the current location
|
1481
1358
|
*
|
1482
1359
|
* @param {String} requestURL The URL to test
|
1483
1360
|
* @returns {boolean} True if URL shares the same origin, otherwise false
|
1484
1361
|
*/
|
1485
|
-
|
1486
1362
|
return function isURLSameOrigin(requestURL) {
|
1487
1363
|
var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
1488
1364
|
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
1489
1365
|
};
|
1490
|
-
}() :
|
1366
|
+
}() :
|
1367
|
+
// Non standard browser envs (web workers, react-native) lack needed support.
|
1491
1368
|
function nonStandardBrowserEnv() {
|
1492
1369
|
return function isURLSameOrigin() {
|
1493
1370
|
return true;
|
@@ -1503,13 +1380,11 @@
|
|
1503
1380
|
*
|
1504
1381
|
* @returns {CanceledError} The created error.
|
1505
1382
|
*/
|
1506
|
-
|
1507
1383
|
function CanceledError(message, config, request) {
|
1508
1384
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
1509
1385
|
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
1510
1386
|
this.name = 'CanceledError';
|
1511
1387
|
}
|
1512
|
-
|
1513
1388
|
utils.inherits(CanceledError, AxiosError, {
|
1514
1389
|
__CANCEL__: true
|
1515
1390
|
});
|
@@ -1519,9 +1394,10 @@
|
|
1519
1394
|
return match && match[1] || '';
|
1520
1395
|
}
|
1521
1396
|
|
1397
|
+
// RawAxiosHeaders whose duplicates are ignored by node
|
1522
1398
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
1523
|
-
|
1524
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
|
+
|
1525
1401
|
/**
|
1526
1402
|
* Parse headers into an object
|
1527
1403
|
*
|
@@ -1536,7 +1412,6 @@
|
|
1536
1412
|
*
|
1537
1413
|
* @returns {Object} Headers parsed into an object
|
1538
1414
|
*/
|
1539
|
-
|
1540
1415
|
var parseHeaders = (function (rawHeaders) {
|
1541
1416
|
var parsed = {};
|
1542
1417
|
var key;
|
@@ -1546,11 +1421,9 @@
|
|
1546
1421
|
i = line.indexOf(':');
|
1547
1422
|
key = line.substring(0, i).trim().toLowerCase();
|
1548
1423
|
val = line.substring(i + 1).trim();
|
1549
|
-
|
1550
1424
|
if (!key || parsed[key] && ignoreDuplicateOf[key]) {
|
1551
1425
|
return;
|
1552
1426
|
}
|
1553
|
-
|
1554
1427
|
if (key === 'set-cookie') {
|
1555
1428
|
if (parsed[key]) {
|
1556
1429
|
parsed[key].push(val);
|
@@ -1566,53 +1439,41 @@
|
|
1566
1439
|
|
1567
1440
|
var $internals = Symbol('internals');
|
1568
1441
|
var $defaults = Symbol('defaults');
|
1569
|
-
|
1570
1442
|
function normalizeHeader(header) {
|
1571
1443
|
return header && String(header).trim().toLowerCase();
|
1572
1444
|
}
|
1573
|
-
|
1574
1445
|
function normalizeValue(value) {
|
1575
1446
|
if (value === false || value == null) {
|
1576
1447
|
return value;
|
1577
1448
|
}
|
1578
|
-
|
1579
|
-
return String(value);
|
1449
|
+
return utils.isArray(value) ? value.map(normalizeValue) : String(value);
|
1580
1450
|
}
|
1581
|
-
|
1582
1451
|
function parseTokens(str) {
|
1583
1452
|
var tokens = Object.create(null);
|
1584
1453
|
var tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
1585
1454
|
var match;
|
1586
|
-
|
1587
1455
|
while (match = tokensRE.exec(str)) {
|
1588
1456
|
tokens[match[1]] = match[2];
|
1589
1457
|
}
|
1590
|
-
|
1591
1458
|
return tokens;
|
1592
1459
|
}
|
1593
|
-
|
1594
1460
|
function matchHeaderValue(context, value, header, filter) {
|
1595
1461
|
if (utils.isFunction(filter)) {
|
1596
1462
|
return filter.call(this, value, header);
|
1597
1463
|
}
|
1598
|
-
|
1599
1464
|
if (!utils.isString(value)) return;
|
1600
|
-
|
1601
1465
|
if (utils.isString(filter)) {
|
1602
1466
|
return value.indexOf(filter) !== -1;
|
1603
1467
|
}
|
1604
|
-
|
1605
1468
|
if (utils.isRegExp(filter)) {
|
1606
1469
|
return filter.test(value);
|
1607
1470
|
}
|
1608
1471
|
}
|
1609
|
-
|
1610
1472
|
function formatHeader(header) {
|
1611
1473
|
return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, function (w, _char, str) {
|
1612
1474
|
return _char.toUpperCase() + str;
|
1613
1475
|
});
|
1614
1476
|
}
|
1615
|
-
|
1616
1477
|
function buildAccessors(obj, header) {
|
1617
1478
|
var accessorName = utils.toCamelCase(' ' + header);
|
1618
1479
|
['get', 'set', 'has'].forEach(function (methodName) {
|
@@ -1624,56 +1485,37 @@
|
|
1624
1485
|
});
|
1625
1486
|
});
|
1626
1487
|
}
|
1627
|
-
|
1628
1488
|
function findKey(obj, key) {
|
1629
1489
|
key = key.toLowerCase();
|
1630
1490
|
var keys = Object.keys(obj);
|
1631
1491
|
var i = keys.length;
|
1632
|
-
|
1633
1492
|
var _key;
|
1634
|
-
|
1635
1493
|
while (i-- > 0) {
|
1636
1494
|
_key = keys[i];
|
1637
|
-
|
1638
1495
|
if (key === _key.toLowerCase()) {
|
1639
1496
|
return _key;
|
1640
1497
|
}
|
1641
1498
|
}
|
1642
|
-
|
1643
1499
|
return null;
|
1644
1500
|
}
|
1645
|
-
|
1646
1501
|
function AxiosHeaders(headers, defaults) {
|
1647
1502
|
headers && this.set(headers);
|
1648
1503
|
this[$defaults] = defaults || null;
|
1649
1504
|
}
|
1650
|
-
|
1651
1505
|
Object.assign(AxiosHeaders.prototype, {
|
1652
1506
|
set: function set(header, valueOrRewrite, rewrite) {
|
1653
1507
|
var self = this;
|
1654
|
-
|
1655
1508
|
function setHeader(_value, _header, _rewrite) {
|
1656
1509
|
var lHeader = normalizeHeader(_header);
|
1657
|
-
|
1658
1510
|
if (!lHeader) {
|
1659
1511
|
throw new Error('header name must be a non-empty string');
|
1660
1512
|
}
|
1661
|
-
|
1662
1513
|
var key = findKey(self, lHeader);
|
1663
|
-
|
1664
1514
|
if (key && _rewrite !== true && (self[key] === false || _rewrite === false)) {
|
1665
1515
|
return;
|
1666
1516
|
}
|
1667
|
-
|
1668
|
-
if (utils.isArray(_value)) {
|
1669
|
-
_value = _value.map(normalizeValue);
|
1670
|
-
} else {
|
1671
|
-
_value = normalizeValue(_value);
|
1672
|
-
}
|
1673
|
-
|
1674
|
-
self[key || _header] = _value;
|
1517
|
+
self[key || _header] = normalizeValue(_value);
|
1675
1518
|
}
|
1676
|
-
|
1677
1519
|
if (utils.isPlainObject(header)) {
|
1678
1520
|
utils.forEach(header, function (_value, _header) {
|
1679
1521
|
setHeader(_value, _header, valueOrRewrite);
|
@@ -1681,69 +1523,55 @@
|
|
1681
1523
|
} else {
|
1682
1524
|
setHeader(valueOrRewrite, header, rewrite);
|
1683
1525
|
}
|
1684
|
-
|
1685
1526
|
return this;
|
1686
1527
|
},
|
1687
1528
|
get: function get(header, parser) {
|
1688
1529
|
header = normalizeHeader(header);
|
1689
1530
|
if (!header) return undefined;
|
1690
1531
|
var key = findKey(this, header);
|
1691
|
-
|
1692
1532
|
if (key) {
|
1693
1533
|
var value = this[key];
|
1694
|
-
|
1695
1534
|
if (!parser) {
|
1696
1535
|
return value;
|
1697
1536
|
}
|
1698
|
-
|
1699
1537
|
if (parser === true) {
|
1700
1538
|
return parseTokens(value);
|
1701
1539
|
}
|
1702
|
-
|
1703
1540
|
if (utils.isFunction(parser)) {
|
1704
1541
|
return parser.call(this, value, key);
|
1705
1542
|
}
|
1706
|
-
|
1707
1543
|
if (utils.isRegExp(parser)) {
|
1708
1544
|
return parser.exec(value);
|
1709
1545
|
}
|
1710
|
-
|
1711
1546
|
throw new TypeError('parser must be boolean|regexp|function');
|
1712
1547
|
}
|
1713
1548
|
},
|
1714
1549
|
has: function has(header, matcher) {
|
1715
1550
|
header = normalizeHeader(header);
|
1716
|
-
|
1717
1551
|
if (header) {
|
1718
1552
|
var key = findKey(this, header);
|
1719
1553
|
return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1720
1554
|
}
|
1721
|
-
|
1722
1555
|
return false;
|
1723
1556
|
},
|
1724
1557
|
"delete": function _delete(header, matcher) {
|
1725
1558
|
var self = this;
|
1726
1559
|
var deleted = false;
|
1727
|
-
|
1728
1560
|
function deleteHeader(_header) {
|
1729
1561
|
_header = normalizeHeader(_header);
|
1730
|
-
|
1731
1562
|
if (_header) {
|
1732
1563
|
var key = findKey(self, _header);
|
1733
|
-
|
1734
1564
|
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
1735
1565
|
delete self[key];
|
1736
1566
|
deleted = true;
|
1737
1567
|
}
|
1738
1568
|
}
|
1739
1569
|
}
|
1740
|
-
|
1741
1570
|
if (utils.isArray(header)) {
|
1742
1571
|
header.forEach(deleteHeader);
|
1743
1572
|
} else {
|
1744
1573
|
deleteHeader(header);
|
1745
1574
|
}
|
1746
|
-
|
1747
1575
|
return deleted;
|
1748
1576
|
},
|
1749
1577
|
clear: function clear() {
|
@@ -1754,29 +1582,25 @@
|
|
1754
1582
|
var headers = {};
|
1755
1583
|
utils.forEach(this, function (value, header) {
|
1756
1584
|
var key = findKey(headers, header);
|
1757
|
-
|
1758
1585
|
if (key) {
|
1759
1586
|
self[key] = normalizeValue(value);
|
1760
1587
|
delete self[header];
|
1761
1588
|
return;
|
1762
1589
|
}
|
1763
|
-
|
1764
1590
|
var normalized = format ? formatHeader(header) : String(header).trim();
|
1765
|
-
|
1766
1591
|
if (normalized !== header) {
|
1767
1592
|
delete self[header];
|
1768
1593
|
}
|
1769
|
-
|
1770
1594
|
self[normalized] = normalizeValue(value);
|
1771
1595
|
headers[normalized] = true;
|
1772
1596
|
});
|
1773
1597
|
return this;
|
1774
1598
|
},
|
1775
|
-
toJSON: function toJSON() {
|
1599
|
+
toJSON: function toJSON(asStrings) {
|
1776
1600
|
var obj = Object.create(null);
|
1777
1601
|
utils.forEach(Object.assign({}, this[$defaults] || null, this), function (value, header) {
|
1778
1602
|
if (value == null || value === false) return;
|
1779
|
-
obj[header] = utils.isArray(value) ? value.join(', ') : value;
|
1603
|
+
obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value;
|
1780
1604
|
});
|
1781
1605
|
return obj;
|
1782
1606
|
}
|
@@ -1786,7 +1610,6 @@
|
|
1786
1610
|
if (utils.isString(thing)) {
|
1787
1611
|
return new this(parseHeaders(thing));
|
1788
1612
|
}
|
1789
|
-
|
1790
1613
|
return thing instanceof this ? thing : new this(thing);
|
1791
1614
|
},
|
1792
1615
|
accessor: function accessor(header) {
|
@@ -1795,16 +1618,13 @@
|
|
1795
1618
|
};
|
1796
1619
|
var accessors = internals.accessors;
|
1797
1620
|
var prototype = this.prototype;
|
1798
|
-
|
1799
1621
|
function defineAccessor(_header) {
|
1800
1622
|
var lHeader = normalizeHeader(_header);
|
1801
|
-
|
1802
1623
|
if (!accessors[lHeader]) {
|
1803
1624
|
buildAccessors(prototype, _header);
|
1804
1625
|
accessors[lHeader] = true;
|
1805
1626
|
}
|
1806
1627
|
}
|
1807
|
-
|
1808
1628
|
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
1809
1629
|
return this;
|
1810
1630
|
}
|
@@ -1819,7 +1639,6 @@
|
|
1819
1639
|
* @param {Number} [min= 1000]
|
1820
1640
|
* @returns {Function}
|
1821
1641
|
*/
|
1822
|
-
|
1823
1642
|
function speedometer(samplesCount, min) {
|
1824
1643
|
samplesCount = samplesCount || 10;
|
1825
1644
|
var bytes = new Array(samplesCount);
|
@@ -1831,31 +1650,24 @@
|
|
1831
1650
|
return function push(chunkLength) {
|
1832
1651
|
var now = Date.now();
|
1833
1652
|
var startedAt = timestamps[tail];
|
1834
|
-
|
1835
1653
|
if (!firstSampleTS) {
|
1836
1654
|
firstSampleTS = now;
|
1837
1655
|
}
|
1838
|
-
|
1839
1656
|
bytes[head] = chunkLength;
|
1840
1657
|
timestamps[head] = now;
|
1841
1658
|
var i = tail;
|
1842
1659
|
var bytesCount = 0;
|
1843
|
-
|
1844
1660
|
while (i !== head) {
|
1845
1661
|
bytesCount += bytes[i++];
|
1846
1662
|
i = i % samplesCount;
|
1847
1663
|
}
|
1848
|
-
|
1849
1664
|
head = (head + 1) % samplesCount;
|
1850
|
-
|
1851
1665
|
if (head === tail) {
|
1852
1666
|
tail = (tail + 1) % samplesCount;
|
1853
1667
|
}
|
1854
|
-
|
1855
1668
|
if (now - firstSampleTS < min) {
|
1856
1669
|
return;
|
1857
1670
|
}
|
1858
|
-
|
1859
1671
|
var passed = startedAt && now - startedAt;
|
1860
1672
|
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
1861
1673
|
};
|
@@ -1863,16 +1675,12 @@
|
|
1863
1675
|
|
1864
1676
|
function progressEventReducer(listener, isDownloadStream) {
|
1865
1677
|
var bytesNotified = 0;
|
1866
|
-
|
1867
1678
|
var _speedometer = speedometer(50, 250);
|
1868
|
-
|
1869
1679
|
return function (e) {
|
1870
1680
|
var loaded = e.loaded;
|
1871
1681
|
var total = e.lengthComputable ? e.total : undefined;
|
1872
1682
|
var progressBytes = loaded - bytesNotified;
|
1873
|
-
|
1874
1683
|
var rate = _speedometer(progressBytes);
|
1875
|
-
|
1876
1684
|
var inRange = loaded <= total;
|
1877
1685
|
bytesNotified = loaded;
|
1878
1686
|
var data = {
|
@@ -1887,47 +1695,42 @@
|
|
1887
1695
|
listener(data);
|
1888
1696
|
};
|
1889
1697
|
}
|
1890
|
-
|
1891
1698
|
function xhrAdapter(config) {
|
1892
1699
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
1893
1700
|
var requestData = config.data;
|
1894
1701
|
var requestHeaders = AxiosHeaders.from(config.headers).normalize();
|
1895
1702
|
var responseType = config.responseType;
|
1896
1703
|
var onCanceled;
|
1897
|
-
|
1898
1704
|
function done() {
|
1899
1705
|
if (config.cancelToken) {
|
1900
1706
|
config.cancelToken.unsubscribe(onCanceled);
|
1901
1707
|
}
|
1902
|
-
|
1903
1708
|
if (config.signal) {
|
1904
1709
|
config.signal.removeEventListener('abort', onCanceled);
|
1905
1710
|
}
|
1906
1711
|
}
|
1907
|
-
|
1908
1712
|
if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
|
1909
1713
|
requestHeaders.setContentType(false); // Let the browser set it
|
1910
1714
|
}
|
1911
1715
|
|
1912
|
-
var request = new XMLHttpRequest();
|
1716
|
+
var request = new XMLHttpRequest();
|
1913
1717
|
|
1718
|
+
// HTTP basic authentication
|
1914
1719
|
if (config.auth) {
|
1915
1720
|
var username = config.auth.username || '';
|
1916
1721
|
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
|
1917
1722
|
requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
|
1918
1723
|
}
|
1919
|
-
|
1920
1724
|
var fullPath = buildFullPath(config.baseURL, config.url);
|
1921
|
-
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
1725
|
+
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
1922
1726
|
|
1727
|
+
// Set the request timeout in MS
|
1923
1728
|
request.timeout = config.timeout;
|
1924
|
-
|
1925
1729
|
function onloadend() {
|
1926
1730
|
if (!request) {
|
1927
1731
|
return;
|
1928
|
-
}
|
1929
|
-
|
1930
|
-
|
1732
|
+
}
|
1733
|
+
// Prepare the response
|
1931
1734
|
var responseHeaders = AxiosHeaders.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
|
1932
1735
|
var responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
|
1933
1736
|
var response = {
|
@@ -1944,11 +1747,11 @@
|
|
1944
1747
|
}, function _reject(err) {
|
1945
1748
|
reject(err);
|
1946
1749
|
done();
|
1947
|
-
}, response);
|
1750
|
+
}, response);
|
1948
1751
|
|
1752
|
+
// Clean up request
|
1949
1753
|
request = null;
|
1950
1754
|
}
|
1951
|
-
|
1952
1755
|
if ('onloadend' in request) {
|
1953
1756
|
// Use onloadend if available
|
1954
1757
|
request.onloadend = onloadend;
|
@@ -1957,97 +1760,95 @@
|
|
1957
1760
|
request.onreadystatechange = function handleLoad() {
|
1958
1761
|
if (!request || request.readyState !== 4) {
|
1959
1762
|
return;
|
1960
|
-
}
|
1763
|
+
}
|
1764
|
+
|
1765
|
+
// The request errored out and we didn't get a response, this will be
|
1961
1766
|
// handled by onerror instead
|
1962
1767
|
// With one exception: request that using file: protocol, most browsers
|
1963
1768
|
// will return status as 0 even though it's a successful request
|
1964
|
-
|
1965
|
-
|
1966
1769
|
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
1967
1770
|
return;
|
1968
|
-
}
|
1771
|
+
}
|
1772
|
+
// readystate handler is calling before onerror or ontimeout handlers,
|
1969
1773
|
// so we should call onloadend on the next 'tick'
|
1970
|
-
|
1971
|
-
|
1972
1774
|
setTimeout(onloadend);
|
1973
1775
|
};
|
1974
|
-
}
|
1975
|
-
|
1776
|
+
}
|
1976
1777
|
|
1778
|
+
// Handle browser request cancellation (as opposed to a manual cancellation)
|
1977
1779
|
request.onabort = function handleAbort() {
|
1978
1780
|
if (!request) {
|
1979
1781
|
return;
|
1980
1782
|
}
|
1783
|
+
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
1981
1784
|
|
1982
|
-
|
1983
|
-
|
1785
|
+
// Clean up request
|
1984
1786
|
request = null;
|
1985
|
-
};
|
1986
|
-
|
1787
|
+
};
|
1987
1788
|
|
1789
|
+
// Handle low level network errors
|
1988
1790
|
request.onerror = function handleError() {
|
1989
1791
|
// Real errors are hidden from us by the browser
|
1990
1792
|
// onerror should only fire if it's a network error
|
1991
|
-
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
|
1793
|
+
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
|
1992
1794
|
|
1795
|
+
// Clean up request
|
1993
1796
|
request = null;
|
1994
|
-
};
|
1995
|
-
|
1797
|
+
};
|
1996
1798
|
|
1799
|
+
// Handle timeout
|
1997
1800
|
request.ontimeout = function handleTimeout() {
|
1998
1801
|
var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
|
1999
1802
|
var transitional = config.transitional || transitionalDefaults;
|
2000
|
-
|
2001
1803
|
if (config.timeoutErrorMessage) {
|
2002
1804
|
timeoutErrorMessage = config.timeoutErrorMessage;
|
2003
1805
|
}
|
1806
|
+
reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
|
2004
1807
|
|
2005
|
-
|
2006
|
-
|
1808
|
+
// Clean up request
|
2007
1809
|
request = null;
|
2008
|
-
};
|
1810
|
+
};
|
1811
|
+
|
1812
|
+
// Add xsrf header
|
2009
1813
|
// This is only done if running in a standard browser environment.
|
2010
1814
|
// Specifically not if we're in a web worker, or react-native.
|
2011
|
-
|
2012
|
-
|
2013
1815
|
if (platform.isStandardBrowserEnv) {
|
2014
1816
|
// Add xsrf header
|
2015
1817
|
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
2016
|
-
|
2017
1818
|
if (xsrfValue) {
|
2018
1819
|
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
2019
1820
|
}
|
2020
|
-
}
|
2021
|
-
|
1821
|
+
}
|
2022
1822
|
|
2023
|
-
|
1823
|
+
// Remove Content-Type if data is undefined
|
1824
|
+
requestData === undefined && requestHeaders.setContentType(null);
|
2024
1825
|
|
1826
|
+
// Add headers to the request
|
2025
1827
|
if ('setRequestHeader' in request) {
|
2026
1828
|
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
2027
1829
|
request.setRequestHeader(key, val);
|
2028
1830
|
});
|
2029
|
-
}
|
2030
|
-
|
1831
|
+
}
|
2031
1832
|
|
1833
|
+
// Add withCredentials to request if needed
|
2032
1834
|
if (!utils.isUndefined(config.withCredentials)) {
|
2033
1835
|
request.withCredentials = !!config.withCredentials;
|
2034
|
-
}
|
2035
|
-
|
1836
|
+
}
|
2036
1837
|
|
1838
|
+
// Add responseType to request if needed
|
2037
1839
|
if (responseType && responseType !== 'json') {
|
2038
1840
|
request.responseType = config.responseType;
|
2039
|
-
}
|
2040
|
-
|
1841
|
+
}
|
2041
1842
|
|
1843
|
+
// Handle progress if needed
|
2042
1844
|
if (typeof config.onDownloadProgress === 'function') {
|
2043
1845
|
request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
|
2044
|
-
}
|
2045
|
-
|
1846
|
+
}
|
2046
1847
|
|
1848
|
+
// Not all browsers support upload events
|
2047
1849
|
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
2048
1850
|
request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
|
2049
1851
|
}
|
2050
|
-
|
2051
1852
|
if (config.cancelToken || config.signal) {
|
2052
1853
|
// Handle cancellation
|
2053
1854
|
// eslint-disable-next-line func-names
|
@@ -2055,27 +1856,22 @@
|
|
2055
1856
|
if (!request) {
|
2056
1857
|
return;
|
2057
1858
|
}
|
2058
|
-
|
2059
1859
|
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
2060
1860
|
request.abort();
|
2061
1861
|
request = null;
|
2062
1862
|
};
|
2063
|
-
|
2064
1863
|
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
2065
|
-
|
2066
1864
|
if (config.signal) {
|
2067
1865
|
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
|
2068
1866
|
}
|
2069
1867
|
}
|
2070
|
-
|
2071
1868
|
var protocol = parseProtocol(fullPath);
|
2072
|
-
|
2073
1869
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
2074
1870
|
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
2075
1871
|
return;
|
2076
|
-
}
|
2077
|
-
|
1872
|
+
}
|
2078
1873
|
|
1874
|
+
// Send the request
|
2079
1875
|
request.send(requestData || null);
|
2080
1876
|
});
|
2081
1877
|
}
|
@@ -2088,18 +1884,14 @@
|
|
2088
1884
|
getAdapter: function getAdapter(nameOrAdapter) {
|
2089
1885
|
if (utils.isString(nameOrAdapter)) {
|
2090
1886
|
var adapter = adapters[nameOrAdapter];
|
2091
|
-
|
2092
1887
|
if (!nameOrAdapter) {
|
2093
1888
|
throw Error(utils.hasOwnProp(nameOrAdapter) ? "Adapter '".concat(nameOrAdapter, "' is not available in the build") : "Can not resolve adapter '".concat(nameOrAdapter, "'"));
|
2094
1889
|
}
|
2095
|
-
|
2096
1890
|
return adapter;
|
2097
1891
|
}
|
2098
|
-
|
2099
1892
|
if (!utils.isFunction(nameOrAdapter)) {
|
2100
1893
|
throw new TypeError('adapter is not a function');
|
2101
1894
|
}
|
2102
|
-
|
2103
1895
|
return nameOrAdapter;
|
2104
1896
|
},
|
2105
1897
|
adapters: adapters
|
@@ -2108,16 +1900,15 @@
|
|
2108
1900
|
var DEFAULT_CONTENT_TYPE = {
|
2109
1901
|
'Content-Type': 'application/x-www-form-urlencoded'
|
2110
1902
|
};
|
1903
|
+
|
2111
1904
|
/**
|
2112
1905
|
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
|
2113
1906
|
* adapter
|
2114
1907
|
*
|
2115
1908
|
* @returns {Function}
|
2116
1909
|
*/
|
2117
|
-
|
2118
1910
|
function getDefaultAdapter() {
|
2119
1911
|
var adapter;
|
2120
|
-
|
2121
1912
|
if (typeof XMLHttpRequest !== 'undefined') {
|
2122
1913
|
// For browsers use XHR adapter
|
2123
1914
|
adapter = adapters$1.getAdapter('xhr');
|
@@ -2125,9 +1916,9 @@
|
|
2125
1916
|
// For node use HTTP adapter
|
2126
1917
|
adapter = adapters$1.getAdapter('http');
|
2127
1918
|
}
|
2128
|
-
|
2129
1919
|
return adapter;
|
2130
1920
|
}
|
1921
|
+
|
2131
1922
|
/**
|
2132
1923
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
2133
1924
|
* of the input
|
@@ -2138,8 +1929,6 @@
|
|
2138
1929
|
*
|
2139
1930
|
* @returns {string} A stringified version of the rawValue.
|
2140
1931
|
*/
|
2141
|
-
|
2142
|
-
|
2143
1932
|
function stringifySafely(rawValue, parser, encoder) {
|
2144
1933
|
if (utils.isString(rawValue)) {
|
2145
1934
|
try {
|
@@ -2151,10 +1940,8 @@
|
|
2151
1940
|
}
|
2152
1941
|
}
|
2153
1942
|
}
|
2154
|
-
|
2155
1943
|
return (encoder || JSON.stringify)(rawValue);
|
2156
1944
|
}
|
2157
|
-
|
2158
1945
|
var defaults = {
|
2159
1946
|
transitional: transitionalDefaults,
|
2160
1947
|
adapter: getDefaultAdapter(),
|
@@ -2162,66 +1949,51 @@
|
|
2162
1949
|
var contentType = headers.getContentType() || '';
|
2163
1950
|
var hasJSONContentType = contentType.indexOf('application/json') > -1;
|
2164
1951
|
var isObjectPayload = utils.isObject(data);
|
2165
|
-
|
2166
1952
|
if (isObjectPayload && utils.isHTMLForm(data)) {
|
2167
1953
|
data = new FormData(data);
|
2168
1954
|
}
|
2169
|
-
|
2170
1955
|
var isFormData = utils.isFormData(data);
|
2171
|
-
|
2172
1956
|
if (isFormData) {
|
2173
1957
|
if (!hasJSONContentType) {
|
2174
1958
|
return data;
|
2175
1959
|
}
|
2176
|
-
|
2177
1960
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
2178
1961
|
}
|
2179
|
-
|
2180
1962
|
if (utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data)) {
|
2181
1963
|
return data;
|
2182
1964
|
}
|
2183
|
-
|
2184
1965
|
if (utils.isArrayBufferView(data)) {
|
2185
1966
|
return data.buffer;
|
2186
1967
|
}
|
2187
|
-
|
2188
1968
|
if (utils.isURLSearchParams(data)) {
|
2189
1969
|
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
2190
1970
|
return data.toString();
|
2191
1971
|
}
|
2192
|
-
|
2193
1972
|
var isFileList;
|
2194
|
-
|
2195
1973
|
if (isObjectPayload) {
|
2196
1974
|
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
2197
1975
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
2198
1976
|
}
|
2199
|
-
|
2200
1977
|
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
2201
1978
|
var _FormData = this.env && this.env.FormData;
|
2202
|
-
|
2203
1979
|
return toFormData(isFileList ? {
|
2204
1980
|
'files[]': data
|
2205
1981
|
} : data, _FormData && new _FormData(), this.formSerializer);
|
2206
1982
|
}
|
2207
1983
|
}
|
2208
|
-
|
2209
1984
|
if (isObjectPayload || hasJSONContentType) {
|
2210
1985
|
headers.setContentType('application/json', false);
|
2211
1986
|
return stringifySafely(data);
|
2212
1987
|
}
|
2213
|
-
|
2214
1988
|
return data;
|
2215
1989
|
}],
|
2216
1990
|
transformResponse: [function transformResponse(data) {
|
2217
1991
|
var transitional = this.transitional || defaults.transitional;
|
2218
1992
|
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
2219
1993
|
var JSONRequested = this.responseType === 'json';
|
2220
|
-
|
2221
1994
|
if (data && utils.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
2222
1995
|
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
2223
1996
|
var strictJSONParsing = !silentJSONParsing && JSONRequested;
|
2224
|
-
|
2225
1997
|
try {
|
2226
1998
|
return JSON.parse(data);
|
2227
1999
|
} catch (e) {
|
@@ -2229,15 +2001,12 @@
|
|
2229
2001
|
if (e.name === 'SyntaxError') {
|
2230
2002
|
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
2231
2003
|
}
|
2232
|
-
|
2233
2004
|
throw e;
|
2234
2005
|
}
|
2235
2006
|
}
|
2236
2007
|
}
|
2237
|
-
|
2238
2008
|
return data;
|
2239
2009
|
}],
|
2240
|
-
|
2241
2010
|
/**
|
2242
2011
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
2243
2012
|
* timeout is not created.
|
@@ -2275,7 +2044,6 @@
|
|
2275
2044
|
*
|
2276
2045
|
* @returns {*} The resulting transformed data
|
2277
2046
|
*/
|
2278
|
-
|
2279
2047
|
function transformData(fns, response) {
|
2280
2048
|
var config = this || defaults;
|
2281
2049
|
var context = response || config;
|
@@ -2299,16 +2067,15 @@
|
|
2299
2067
|
*
|
2300
2068
|
* @returns {void}
|
2301
2069
|
*/
|
2302
|
-
|
2303
2070
|
function throwIfCancellationRequested(config) {
|
2304
2071
|
if (config.cancelToken) {
|
2305
2072
|
config.cancelToken.throwIfRequested();
|
2306
2073
|
}
|
2307
|
-
|
2308
2074
|
if (config.signal && config.signal.aborted) {
|
2309
2075
|
throw new CanceledError();
|
2310
2076
|
}
|
2311
2077
|
}
|
2078
|
+
|
2312
2079
|
/**
|
2313
2080
|
* Dispatch a request to the server using the configured adapter.
|
2314
2081
|
*
|
@@ -2316,30 +2083,30 @@
|
|
2316
2083
|
*
|
2317
2084
|
* @returns {Promise} The Promise to be fulfilled
|
2318
2085
|
*/
|
2319
|
-
|
2320
|
-
|
2321
2086
|
function dispatchRequest(config) {
|
2322
2087
|
throwIfCancellationRequested(config);
|
2323
|
-
config.headers = AxiosHeaders.from(config.headers);
|
2088
|
+
config.headers = AxiosHeaders.from(config.headers);
|
2324
2089
|
|
2090
|
+
// Transform request data
|
2325
2091
|
config.data = transformData.call(config, config.transformRequest);
|
2326
2092
|
var adapter = config.adapter || defaults.adapter;
|
2327
2093
|
return adapter(config).then(function onAdapterResolution(response) {
|
2328
|
-
throwIfCancellationRequested(config);
|
2094
|
+
throwIfCancellationRequested(config);
|
2329
2095
|
|
2096
|
+
// Transform response data
|
2330
2097
|
response.data = transformData.call(config, config.transformResponse, response);
|
2331
2098
|
response.headers = AxiosHeaders.from(response.headers);
|
2332
2099
|
return response;
|
2333
2100
|
}, function onAdapterRejection(reason) {
|
2334
2101
|
if (!isCancel(reason)) {
|
2335
|
-
throwIfCancellationRequested(config);
|
2102
|
+
throwIfCancellationRequested(config);
|
2336
2103
|
|
2104
|
+
// Transform response data
|
2337
2105
|
if (reason && reason.response) {
|
2338
2106
|
reason.response.data = transformData.call(config, config.transformResponse, reason.response);
|
2339
2107
|
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
2340
2108
|
}
|
2341
2109
|
}
|
2342
|
-
|
2343
2110
|
return Promise.reject(reason);
|
2344
2111
|
});
|
2345
2112
|
}
|
@@ -2353,12 +2120,10 @@
|
|
2353
2120
|
*
|
2354
2121
|
* @returns {Object} New object resulting from merging config2 to config1
|
2355
2122
|
*/
|
2356
|
-
|
2357
2123
|
function mergeConfig(config1, config2) {
|
2358
2124
|
// eslint-disable-next-line no-param-reassign
|
2359
2125
|
config2 = config2 || {};
|
2360
2126
|
var config = {};
|
2361
|
-
|
2362
2127
|
function getMergedValue(target, source) {
|
2363
2128
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
2364
2129
|
return utils.merge(target, source);
|
@@ -2367,36 +2132,35 @@
|
|
2367
2132
|
} else if (utils.isArray(source)) {
|
2368
2133
|
return source.slice();
|
2369
2134
|
}
|
2370
|
-
|
2371
2135
|
return source;
|
2372
|
-
}
|
2373
|
-
|
2136
|
+
}
|
2374
2137
|
|
2138
|
+
// eslint-disable-next-line consistent-return
|
2375
2139
|
function mergeDeepProperties(prop) {
|
2376
2140
|
if (!utils.isUndefined(config2[prop])) {
|
2377
2141
|
return getMergedValue(config1[prop], config2[prop]);
|
2378
2142
|
} else if (!utils.isUndefined(config1[prop])) {
|
2379
2143
|
return getMergedValue(undefined, config1[prop]);
|
2380
2144
|
}
|
2381
|
-
}
|
2382
|
-
|
2145
|
+
}
|
2383
2146
|
|
2147
|
+
// eslint-disable-next-line consistent-return
|
2384
2148
|
function valueFromConfig2(prop) {
|
2385
2149
|
if (!utils.isUndefined(config2[prop])) {
|
2386
2150
|
return getMergedValue(undefined, config2[prop]);
|
2387
2151
|
}
|
2388
|
-
}
|
2389
|
-
|
2152
|
+
}
|
2390
2153
|
|
2154
|
+
// eslint-disable-next-line consistent-return
|
2391
2155
|
function defaultToConfig2(prop) {
|
2392
2156
|
if (!utils.isUndefined(config2[prop])) {
|
2393
2157
|
return getMergedValue(undefined, config2[prop]);
|
2394
2158
|
} else if (!utils.isUndefined(config1[prop])) {
|
2395
2159
|
return getMergedValue(undefined, config1[prop]);
|
2396
2160
|
}
|
2397
|
-
}
|
2398
|
-
|
2161
|
+
}
|
2399
2162
|
|
2163
|
+
// eslint-disable-next-line consistent-return
|
2400
2164
|
function mergeDirectKeys(prop) {
|
2401
2165
|
if (prop in config2) {
|
2402
2166
|
return getMergedValue(config1[prop], config2[prop]);
|
@@ -2404,7 +2168,6 @@
|
|
2404
2168
|
return getMergedValue(undefined, config1[prop]);
|
2405
2169
|
}
|
2406
2170
|
}
|
2407
|
-
|
2408
2171
|
var mergeMap = {
|
2409
2172
|
'url': valueFromConfig2,
|
2410
2173
|
'method': valueFromConfig2,
|
@@ -2442,16 +2205,18 @@
|
|
2442
2205
|
return config;
|
2443
2206
|
}
|
2444
2207
|
|
2445
|
-
var VERSION = "1.1.
|
2208
|
+
var VERSION = "1.1.3";
|
2446
2209
|
|
2447
|
-
var validators$1 = {};
|
2210
|
+
var validators$1 = {};
|
2448
2211
|
|
2212
|
+
// eslint-disable-next-line func-names
|
2449
2213
|
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function (type, i) {
|
2450
2214
|
validators$1[type] = function validator(thing) {
|
2451
2215
|
return _typeof(thing) === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
2452
2216
|
};
|
2453
2217
|
});
|
2454
2218
|
var deprecatedWarnings = {};
|
2219
|
+
|
2455
2220
|
/**
|
2456
2221
|
* Transitional option validator
|
2457
2222
|
*
|
@@ -2461,27 +2226,25 @@
|
|
2461
2226
|
*
|
2462
2227
|
* @returns {function}
|
2463
2228
|
*/
|
2464
|
-
|
2465
2229
|
validators$1.transitional = function transitional(validator, version, message) {
|
2466
2230
|
function formatMessage(opt, desc) {
|
2467
2231
|
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
2468
|
-
}
|
2469
|
-
|
2232
|
+
}
|
2470
2233
|
|
2234
|
+
// eslint-disable-next-line func-names
|
2471
2235
|
return function (value, opt, opts) {
|
2472
2236
|
if (validator === false) {
|
2473
2237
|
throw new AxiosError(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError.ERR_DEPRECATED);
|
2474
2238
|
}
|
2475
|
-
|
2476
2239
|
if (version && !deprecatedWarnings[opt]) {
|
2477
|
-
deprecatedWarnings[opt] = true;
|
2478
|
-
|
2240
|
+
deprecatedWarnings[opt] = true;
|
2241
|
+
// eslint-disable-next-line no-console
|
2479
2242
|
console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
|
2480
2243
|
}
|
2481
|
-
|
2482
2244
|
return validator ? validator(value, opt, opts) : true;
|
2483
2245
|
};
|
2484
2246
|
};
|
2247
|
+
|
2485
2248
|
/**
|
2486
2249
|
* Assert object's properties type
|
2487
2250
|
*
|
@@ -2492,42 +2255,35 @@
|
|
2492
2255
|
* @returns {object}
|
2493
2256
|
*/
|
2494
2257
|
|
2495
|
-
|
2496
2258
|
function assertOptions(options, schema, allowUnknown) {
|
2497
2259
|
if (_typeof(options) !== 'object') {
|
2498
2260
|
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
2499
2261
|
}
|
2500
|
-
|
2501
2262
|
var keys = Object.keys(options);
|
2502
2263
|
var i = keys.length;
|
2503
|
-
|
2504
2264
|
while (i-- > 0) {
|
2505
2265
|
var opt = keys[i];
|
2506
2266
|
var validator = schema[opt];
|
2507
|
-
|
2508
2267
|
if (validator) {
|
2509
2268
|
var value = options[opt];
|
2510
2269
|
var result = value === undefined || validator(value, opt, options);
|
2511
|
-
|
2512
2270
|
if (result !== true) {
|
2513
2271
|
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
2514
2272
|
}
|
2515
|
-
|
2516
2273
|
continue;
|
2517
2274
|
}
|
2518
|
-
|
2519
2275
|
if (allowUnknown !== true) {
|
2520
2276
|
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
|
2521
2277
|
}
|
2522
2278
|
}
|
2523
2279
|
}
|
2524
|
-
|
2525
2280
|
var validator = {
|
2526
2281
|
assertOptions: assertOptions,
|
2527
2282
|
validators: validators$1
|
2528
2283
|
};
|
2529
2284
|
|
2530
2285
|
var validators = validator.validators;
|
2286
|
+
|
2531
2287
|
/**
|
2532
2288
|
* Create a new instance of Axios
|
2533
2289
|
*
|
@@ -2535,17 +2291,16 @@
|
|
2535
2291
|
*
|
2536
2292
|
* @return {Axios} A new instance of Axios
|
2537
2293
|
*/
|
2538
|
-
|
2539
2294
|
var Axios = /*#__PURE__*/function () {
|
2540
2295
|
function Axios(instanceConfig) {
|
2541
2296
|
_classCallCheck(this, Axios);
|
2542
|
-
|
2543
2297
|
this.defaults = instanceConfig;
|
2544
2298
|
this.interceptors = {
|
2545
2299
|
request: new InterceptorManager(),
|
2546
2300
|
response: new InterceptorManager()
|
2547
2301
|
};
|
2548
2302
|
}
|
2303
|
+
|
2549
2304
|
/**
|
2550
2305
|
* Dispatch a request
|
2551
2306
|
*
|
@@ -2554,8 +2309,6 @@
|
|
2554
2309
|
*
|
2555
2310
|
* @returns {Promise} The Promise to be fulfilled
|
2556
2311
|
*/
|
2557
|
-
|
2558
|
-
|
2559
2312
|
_createClass(Axios, [{
|
2560
2313
|
key: "request",
|
2561
2314
|
value: function request(configOrUrl, config) {
|
@@ -2567,34 +2320,41 @@
|
|
2567
2320
|
} else {
|
2568
2321
|
config = configOrUrl || {};
|
2569
2322
|
}
|
2570
|
-
|
2571
2323
|
config = mergeConfig(this.defaults, config);
|
2572
|
-
var
|
2573
|
-
|
2324
|
+
var _config = config,
|
2325
|
+
transitional = _config.transitional,
|
2326
|
+
paramsSerializer = _config.paramsSerializer;
|
2574
2327
|
if (transitional !== undefined) {
|
2575
2328
|
validator.assertOptions(transitional, {
|
2576
2329
|
silentJSONParsing: validators.transitional(validators["boolean"]),
|
2577
2330
|
forcedJSONParsing: validators.transitional(validators["boolean"]),
|
2578
2331
|
clarifyTimeoutError: validators.transitional(validators["boolean"])
|
2579
2332
|
}, false);
|
2580
|
-
}
|
2581
|
-
|
2333
|
+
}
|
2334
|
+
if (paramsSerializer !== undefined) {
|
2335
|
+
validator.assertOptions(paramsSerializer, {
|
2336
|
+
encode: validators["function"],
|
2337
|
+
serialize: validators["function"]
|
2338
|
+
}, true);
|
2339
|
+
}
|
2582
2340
|
|
2583
|
-
|
2341
|
+
// Set config.method
|
2342
|
+
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
2584
2343
|
|
2344
|
+
// Flatten headers
|
2585
2345
|
var defaultHeaders = config.headers && utils.merge(config.headers.common, config.headers[config.method]);
|
2586
2346
|
defaultHeaders && utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function cleanHeaderConfig(method) {
|
2587
2347
|
delete config.headers[method];
|
2588
2348
|
});
|
2589
|
-
config.headers = new AxiosHeaders(config.headers, defaultHeaders);
|
2349
|
+
config.headers = new AxiosHeaders(config.headers, defaultHeaders);
|
2590
2350
|
|
2351
|
+
// filter out skipped interceptors
|
2591
2352
|
var requestInterceptorChain = [];
|
2592
2353
|
var synchronousRequestInterceptors = true;
|
2593
2354
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
2594
2355
|
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
2595
2356
|
return;
|
2596
2357
|
}
|
2597
|
-
|
2598
2358
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
2599
2359
|
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
2600
2360
|
});
|
@@ -2605,29 +2365,23 @@
|
|
2605
2365
|
var promise;
|
2606
2366
|
var i = 0;
|
2607
2367
|
var len;
|
2608
|
-
|
2609
2368
|
if (!synchronousRequestInterceptors) {
|
2610
2369
|
var chain = [dispatchRequest.bind(this), undefined];
|
2611
2370
|
chain.unshift.apply(chain, requestInterceptorChain);
|
2612
2371
|
chain.push.apply(chain, responseInterceptorChain);
|
2613
2372
|
len = chain.length;
|
2614
2373
|
promise = Promise.resolve(config);
|
2615
|
-
|
2616
2374
|
while (i < len) {
|
2617
2375
|
promise = promise.then(chain[i++], chain[i++]);
|
2618
2376
|
}
|
2619
|
-
|
2620
2377
|
return promise;
|
2621
2378
|
}
|
2622
|
-
|
2623
2379
|
len = requestInterceptorChain.length;
|
2624
2380
|
var newConfig = config;
|
2625
2381
|
i = 0;
|
2626
|
-
|
2627
2382
|
while (i < len) {
|
2628
2383
|
var onFulfilled = requestInterceptorChain[i++];
|
2629
2384
|
var onRejected = requestInterceptorChain[i++];
|
2630
|
-
|
2631
2385
|
try {
|
2632
2386
|
newConfig = onFulfilled(newConfig);
|
2633
2387
|
} catch (error) {
|
@@ -2635,20 +2389,16 @@
|
|
2635
2389
|
break;
|
2636
2390
|
}
|
2637
2391
|
}
|
2638
|
-
|
2639
2392
|
try {
|
2640
2393
|
promise = dispatchRequest.call(this, newConfig);
|
2641
2394
|
} catch (error) {
|
2642
2395
|
return Promise.reject(error);
|
2643
2396
|
}
|
2644
|
-
|
2645
2397
|
i = 0;
|
2646
2398
|
len = responseInterceptorChain.length;
|
2647
|
-
|
2648
2399
|
while (i < len) {
|
2649
2400
|
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
2650
2401
|
}
|
2651
|
-
|
2652
2402
|
return promise;
|
2653
2403
|
}
|
2654
2404
|
}, {
|
@@ -2659,11 +2409,8 @@
|
|
2659
2409
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
2660
2410
|
}
|
2661
2411
|
}]);
|
2662
|
-
|
2663
2412
|
return Axios;
|
2664
2413
|
}(); // Provide aliases for supported request methods
|
2665
|
-
|
2666
|
-
|
2667
2414
|
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
2668
2415
|
/*eslint func-names:0*/
|
2669
2416
|
Axios.prototype[method] = function (url, config) {
|
@@ -2676,6 +2423,7 @@
|
|
2676
2423
|
});
|
2677
2424
|
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
2678
2425
|
/*eslint func-names:0*/
|
2426
|
+
|
2679
2427
|
function generateHTTPMethod(isForm) {
|
2680
2428
|
return function httpMethod(url, data, config) {
|
2681
2429
|
return this.request(mergeConfig(config || {}, {
|
@@ -2688,7 +2436,6 @@
|
|
2688
2436
|
}));
|
2689
2437
|
};
|
2690
2438
|
}
|
2691
|
-
|
2692
2439
|
Axios.prototype[method] = generateHTTPMethod();
|
2693
2440
|
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
2694
2441
|
});
|
@@ -2700,63 +2447,54 @@
|
|
2700
2447
|
*
|
2701
2448
|
* @returns {CancelToken}
|
2702
2449
|
*/
|
2703
|
-
|
2704
2450
|
var CancelToken = /*#__PURE__*/function () {
|
2705
2451
|
function CancelToken(executor) {
|
2706
2452
|
_classCallCheck(this, CancelToken);
|
2707
|
-
|
2708
2453
|
if (typeof executor !== 'function') {
|
2709
2454
|
throw new TypeError('executor must be a function.');
|
2710
2455
|
}
|
2711
|
-
|
2712
2456
|
var resolvePromise;
|
2713
2457
|
this.promise = new Promise(function promiseExecutor(resolve) {
|
2714
2458
|
resolvePromise = resolve;
|
2715
2459
|
});
|
2716
|
-
var token = this;
|
2460
|
+
var token = this;
|
2717
2461
|
|
2462
|
+
// eslint-disable-next-line func-names
|
2718
2463
|
this.promise.then(function (cancel) {
|
2719
2464
|
if (!token._listeners) return;
|
2720
2465
|
var i = token._listeners.length;
|
2721
|
-
|
2722
2466
|
while (i-- > 0) {
|
2723
2467
|
token._listeners[i](cancel);
|
2724
2468
|
}
|
2725
|
-
|
2726
2469
|
token._listeners = null;
|
2727
|
-
});
|
2470
|
+
});
|
2728
2471
|
|
2472
|
+
// eslint-disable-next-line func-names
|
2729
2473
|
this.promise.then = function (onfulfilled) {
|
2730
|
-
var _resolve;
|
2731
|
-
|
2732
|
-
|
2474
|
+
var _resolve;
|
2475
|
+
// eslint-disable-next-line func-names
|
2733
2476
|
var promise = new Promise(function (resolve) {
|
2734
2477
|
token.subscribe(resolve);
|
2735
2478
|
_resolve = resolve;
|
2736
2479
|
}).then(onfulfilled);
|
2737
|
-
|
2738
2480
|
promise.cancel = function reject() {
|
2739
2481
|
token.unsubscribe(_resolve);
|
2740
2482
|
};
|
2741
|
-
|
2742
2483
|
return promise;
|
2743
2484
|
};
|
2744
|
-
|
2745
2485
|
executor(function cancel(message, config, request) {
|
2746
2486
|
if (token.reason) {
|
2747
2487
|
// Cancellation has already been requested
|
2748
2488
|
return;
|
2749
2489
|
}
|
2750
|
-
|
2751
2490
|
token.reason = new CanceledError(message, config, request);
|
2752
2491
|
resolvePromise(token.reason);
|
2753
2492
|
});
|
2754
2493
|
}
|
2494
|
+
|
2755
2495
|
/**
|
2756
2496
|
* Throws a `CanceledError` if cancellation has been requested.
|
2757
2497
|
*/
|
2758
|
-
|
2759
|
-
|
2760
2498
|
_createClass(CancelToken, [{
|
2761
2499
|
key: "throwIfRequested",
|
2762
2500
|
value: function throwIfRequested() {
|
@@ -2764,10 +2502,10 @@
|
|
2764
2502
|
throw this.reason;
|
2765
2503
|
}
|
2766
2504
|
}
|
2505
|
+
|
2767
2506
|
/**
|
2768
2507
|
* Subscribe to the cancel signal
|
2769
2508
|
*/
|
2770
|
-
|
2771
2509
|
}, {
|
2772
2510
|
key: "subscribe",
|
2773
2511
|
value: function subscribe(listener) {
|
@@ -2775,35 +2513,32 @@
|
|
2775
2513
|
listener(this.reason);
|
2776
2514
|
return;
|
2777
2515
|
}
|
2778
|
-
|
2779
2516
|
if (this._listeners) {
|
2780
2517
|
this._listeners.push(listener);
|
2781
2518
|
} else {
|
2782
2519
|
this._listeners = [listener];
|
2783
2520
|
}
|
2784
2521
|
}
|
2522
|
+
|
2785
2523
|
/**
|
2786
2524
|
* Unsubscribe from the cancel signal
|
2787
2525
|
*/
|
2788
|
-
|
2789
2526
|
}, {
|
2790
2527
|
key: "unsubscribe",
|
2791
2528
|
value: function unsubscribe(listener) {
|
2792
2529
|
if (!this._listeners) {
|
2793
2530
|
return;
|
2794
2531
|
}
|
2795
|
-
|
2796
2532
|
var index = this._listeners.indexOf(listener);
|
2797
|
-
|
2798
2533
|
if (index !== -1) {
|
2799
2534
|
this._listeners.splice(index, 1);
|
2800
2535
|
}
|
2801
2536
|
}
|
2537
|
+
|
2802
2538
|
/**
|
2803
2539
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
2804
2540
|
* cancels the `CancelToken`.
|
2805
2541
|
*/
|
2806
|
-
|
2807
2542
|
}], [{
|
2808
2543
|
key: "source",
|
2809
2544
|
value: function source() {
|
@@ -2817,7 +2552,6 @@
|
|
2817
2552
|
};
|
2818
2553
|
}
|
2819
2554
|
}]);
|
2820
|
-
|
2821
2555
|
return CancelToken;
|
2822
2556
|
}();
|
2823
2557
|
|
@@ -2842,7 +2576,6 @@
|
|
2842
2576
|
*
|
2843
2577
|
* @returns {Function}
|
2844
2578
|
*/
|
2845
|
-
|
2846
2579
|
function spread(callback) {
|
2847
2580
|
return function wrap(arr) {
|
2848
2581
|
return callback.apply(null, arr);
|
@@ -2856,7 +2589,6 @@
|
|
2856
2589
|
*
|
2857
2590
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
2858
2591
|
*/
|
2859
|
-
|
2860
2592
|
function isAxiosError(payload) {
|
2861
2593
|
return utils.isObject(payload) && payload.isAxiosError === true;
|
2862
2594
|
}
|
@@ -2868,56 +2600,59 @@
|
|
2868
2600
|
*
|
2869
2601
|
* @returns {Axios} A new instance of Axios
|
2870
2602
|
*/
|
2871
|
-
|
2872
2603
|
function createInstance(defaultConfig) {
|
2873
2604
|
var context = new Axios(defaultConfig);
|
2874
|
-
var instance = bind(Axios.prototype.request, context);
|
2605
|
+
var instance = bind(Axios.prototype.request, context);
|
2875
2606
|
|
2607
|
+
// Copy axios.prototype to instance
|
2876
2608
|
utils.extend(instance, Axios.prototype, context, {
|
2877
2609
|
allOwnKeys: true
|
2878
|
-
});
|
2610
|
+
});
|
2879
2611
|
|
2612
|
+
// Copy context to instance
|
2880
2613
|
utils.extend(instance, context, null, {
|
2881
2614
|
allOwnKeys: true
|
2882
|
-
});
|
2615
|
+
});
|
2883
2616
|
|
2617
|
+
// Factory for creating new instances
|
2884
2618
|
instance.create = function create(instanceConfig) {
|
2885
2619
|
return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
2886
2620
|
};
|
2887
|
-
|
2888
2621
|
return instance;
|
2889
|
-
}
|
2890
|
-
|
2622
|
+
}
|
2891
2623
|
|
2892
|
-
|
2624
|
+
// Create the default instance to be exported
|
2625
|
+
var axios = createInstance(defaults);
|
2893
2626
|
|
2894
|
-
|
2627
|
+
// Expose Axios class to allow class inheritance
|
2628
|
+
axios.Axios = Axios;
|
2895
2629
|
|
2630
|
+
// Expose Cancel & CancelToken
|
2896
2631
|
axios.CanceledError = CanceledError;
|
2897
2632
|
axios.CancelToken = CancelToken;
|
2898
2633
|
axios.isCancel = isCancel;
|
2899
2634
|
axios.VERSION = VERSION;
|
2900
|
-
axios.toFormData = toFormData;
|
2635
|
+
axios.toFormData = toFormData;
|
2901
2636
|
|
2902
|
-
|
2637
|
+
// Expose AxiosError class
|
2638
|
+
axios.AxiosError = AxiosError;
|
2903
2639
|
|
2904
|
-
|
2640
|
+
// alias for CanceledError for backward compatibility
|
2641
|
+
axios.Cancel = axios.CanceledError;
|
2905
2642
|
|
2643
|
+
// Expose all/spread
|
2906
2644
|
axios.all = function all(promises) {
|
2907
2645
|
return Promise.all(promises);
|
2908
2646
|
};
|
2647
|
+
axios.spread = spread;
|
2909
2648
|
|
2910
|
-
|
2911
|
-
|
2649
|
+
// Expose isAxiosError
|
2912
2650
|
axios.isAxiosError = isAxiosError;
|
2913
|
-
|
2914
2651
|
axios.formToJSON = function (thing) {
|
2915
2652
|
return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
2916
2653
|
};
|
2917
2654
|
|
2918
|
-
|
2919
|
-
|
2920
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
2655
|
+
return axios;
|
2921
2656
|
|
2922
2657
|
}));
|
2923
2658
|
//# sourceMappingURL=axios.js.map
|