1 | // Axios v1.7.7 Copyright (c) 2024 Matt Zabriskie and contributors
|
---|
2 | function bind(fn, thisArg) {
|
---|
3 | return function wrap() {
|
---|
4 | return fn.apply(thisArg, arguments);
|
---|
5 | };
|
---|
6 | }
|
---|
7 |
|
---|
8 | // utils is a library of generic helper functions non-specific to axios
|
---|
9 |
|
---|
10 | const {toString} = Object.prototype;
|
---|
11 | const {getPrototypeOf} = Object;
|
---|
12 |
|
---|
13 | const kindOf = (cache => thing => {
|
---|
14 | const str = toString.call(thing);
|
---|
15 | return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
---|
16 | })(Object.create(null));
|
---|
17 |
|
---|
18 | const kindOfTest = (type) => {
|
---|
19 | type = type.toLowerCase();
|
---|
20 | return (thing) => kindOf(thing) === type
|
---|
21 | };
|
---|
22 |
|
---|
23 | const typeOfTest = type => thing => typeof thing === type;
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Determine if a value is an Array
|
---|
27 | *
|
---|
28 | * @param {Object} val The value to test
|
---|
29 | *
|
---|
30 | * @returns {boolean} True if value is an Array, otherwise false
|
---|
31 | */
|
---|
32 | const {isArray} = Array;
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Determine if a value is undefined
|
---|
36 | *
|
---|
37 | * @param {*} val The value to test
|
---|
38 | *
|
---|
39 | * @returns {boolean} True if the value is undefined, otherwise false
|
---|
40 | */
|
---|
41 | const isUndefined = typeOfTest('undefined');
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Determine if a value is a Buffer
|
---|
45 | *
|
---|
46 | * @param {*} val The value to test
|
---|
47 | *
|
---|
48 | * @returns {boolean} True if value is a Buffer, otherwise false
|
---|
49 | */
|
---|
50 | function isBuffer(val) {
|
---|
51 | return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
---|
52 | && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
---|
53 | }
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Determine if a value is an ArrayBuffer
|
---|
57 | *
|
---|
58 | * @param {*} val The value to test
|
---|
59 | *
|
---|
60 | * @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
---|
61 | */
|
---|
62 | const isArrayBuffer = kindOfTest('ArrayBuffer');
|
---|
63 |
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Determine if a value is a view on an ArrayBuffer
|
---|
67 | *
|
---|
68 | * @param {*} val The value to test
|
---|
69 | *
|
---|
70 | * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
---|
71 | */
|
---|
72 | function isArrayBufferView(val) {
|
---|
73 | let result;
|
---|
74 | if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
---|
75 | result = ArrayBuffer.isView(val);
|
---|
76 | } else {
|
---|
77 | result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
|
---|
78 | }
|
---|
79 | return result;
|
---|
80 | }
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * Determine if a value is a String
|
---|
84 | *
|
---|
85 | * @param {*} val The value to test
|
---|
86 | *
|
---|
87 | * @returns {boolean} True if value is a String, otherwise false
|
---|
88 | */
|
---|
89 | const isString = typeOfTest('string');
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Determine if a value is a Function
|
---|
93 | *
|
---|
94 | * @param {*} val The value to test
|
---|
95 | * @returns {boolean} True if value is a Function, otherwise false
|
---|
96 | */
|
---|
97 | const isFunction = typeOfTest('function');
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Determine if a value is a Number
|
---|
101 | *
|
---|
102 | * @param {*} val The value to test
|
---|
103 | *
|
---|
104 | * @returns {boolean} True if value is a Number, otherwise false
|
---|
105 | */
|
---|
106 | const isNumber = typeOfTest('number');
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * Determine if a value is an Object
|
---|
110 | *
|
---|
111 | * @param {*} thing The value to test
|
---|
112 | *
|
---|
113 | * @returns {boolean} True if value is an Object, otherwise false
|
---|
114 | */
|
---|
115 | const isObject = (thing) => thing !== null && typeof thing === 'object';
|
---|
116 |
|
---|
117 | /**
|
---|
118 | * Determine if a value is a Boolean
|
---|
119 | *
|
---|
120 | * @param {*} thing The value to test
|
---|
121 | * @returns {boolean} True if value is a Boolean, otherwise false
|
---|
122 | */
|
---|
123 | const isBoolean = thing => thing === true || thing === false;
|
---|
124 |
|
---|
125 | /**
|
---|
126 | * Determine if a value is a plain Object
|
---|
127 | *
|
---|
128 | * @param {*} val The value to test
|
---|
129 | *
|
---|
130 | * @returns {boolean} True if value is a plain Object, otherwise false
|
---|
131 | */
|
---|
132 | const isPlainObject = (val) => {
|
---|
133 | if (kindOf(val) !== 'object') {
|
---|
134 | return false;
|
---|
135 | }
|
---|
136 |
|
---|
137 | const prototype = getPrototypeOf(val);
|
---|
138 | return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
---|
139 | };
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * Determine if a value is a Date
|
---|
143 | *
|
---|
144 | * @param {*} val The value to test
|
---|
145 | *
|
---|
146 | * @returns {boolean} True if value is a Date, otherwise false
|
---|
147 | */
|
---|
148 | const isDate = kindOfTest('Date');
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * Determine if a value is a File
|
---|
152 | *
|
---|
153 | * @param {*} val The value to test
|
---|
154 | *
|
---|
155 | * @returns {boolean} True if value is a File, otherwise false
|
---|
156 | */
|
---|
157 | const isFile = kindOfTest('File');
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * Determine if a value is a Blob
|
---|
161 | *
|
---|
162 | * @param {*} val The value to test
|
---|
163 | *
|
---|
164 | * @returns {boolean} True if value is a Blob, otherwise false
|
---|
165 | */
|
---|
166 | const isBlob = kindOfTest('Blob');
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * Determine if a value is a FileList
|
---|
170 | *
|
---|
171 | * @param {*} val The value to test
|
---|
172 | *
|
---|
173 | * @returns {boolean} True if value is a File, otherwise false
|
---|
174 | */
|
---|
175 | const isFileList = kindOfTest('FileList');
|
---|
176 |
|
---|
177 | /**
|
---|
178 | * Determine if a value is a Stream
|
---|
179 | *
|
---|
180 | * @param {*} val The value to test
|
---|
181 | *
|
---|
182 | * @returns {boolean} True if value is a Stream, otherwise false
|
---|
183 | */
|
---|
184 | const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Determine if a value is a FormData
|
---|
188 | *
|
---|
189 | * @param {*} thing The value to test
|
---|
190 | *
|
---|
191 | * @returns {boolean} True if value is an FormData, otherwise false
|
---|
192 | */
|
---|
193 | const isFormData = (thing) => {
|
---|
194 | let kind;
|
---|
195 | return thing && (
|
---|
196 | (typeof FormData === 'function' && thing instanceof FormData) || (
|
---|
197 | isFunction(thing.append) && (
|
---|
198 | (kind = kindOf(thing)) === 'formdata' ||
|
---|
199 | // detect form-data instance
|
---|
200 | (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
---|
201 | )
|
---|
202 | )
|
---|
203 | )
|
---|
204 | };
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * Determine if a value is a URLSearchParams object
|
---|
208 | *
|
---|
209 | * @param {*} val The value to test
|
---|
210 | *
|
---|
211 | * @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
---|
212 | */
|
---|
213 | const isURLSearchParams = kindOfTest('URLSearchParams');
|
---|
214 |
|
---|
215 | const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
|
---|
216 |
|
---|
217 | /**
|
---|
218 | * Trim excess whitespace off the beginning and end of a string
|
---|
219 | *
|
---|
220 | * @param {String} str The String to trim
|
---|
221 | *
|
---|
222 | * @returns {String} The String freed of excess whitespace
|
---|
223 | */
|
---|
224 | const trim = (str) => str.trim ?
|
---|
225 | str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
---|
226 |
|
---|
227 | /**
|
---|
228 | * Iterate over an Array or an Object invoking a function for each item.
|
---|
229 | *
|
---|
230 | * If `obj` is an Array callback will be called passing
|
---|
231 | * the value, index, and complete array for each item.
|
---|
232 | *
|
---|
233 | * If 'obj' is an Object callback will be called passing
|
---|
234 | * the value, key, and complete object for each property.
|
---|
235 | *
|
---|
236 | * @param {Object|Array} obj The object to iterate
|
---|
237 | * @param {Function} fn The callback to invoke for each item
|
---|
238 | *
|
---|
239 | * @param {Boolean} [allOwnKeys = false]
|
---|
240 | * @returns {any}
|
---|
241 | */
|
---|
242 | function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
---|
243 | // Don't bother if no value provided
|
---|
244 | if (obj === null || typeof obj === 'undefined') {
|
---|
245 | return;
|
---|
246 | }
|
---|
247 |
|
---|
248 | let i;
|
---|
249 | let l;
|
---|
250 |
|
---|
251 | // Force an array if not already something iterable
|
---|
252 | if (typeof obj !== 'object') {
|
---|
253 | /*eslint no-param-reassign:0*/
|
---|
254 | obj = [obj];
|
---|
255 | }
|
---|
256 |
|
---|
257 | if (isArray(obj)) {
|
---|
258 | // Iterate over array values
|
---|
259 | for (i = 0, l = obj.length; i < l; i++) {
|
---|
260 | fn.call(null, obj[i], i, obj);
|
---|
261 | }
|
---|
262 | } else {
|
---|
263 | // Iterate over object keys
|
---|
264 | const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
---|
265 | const len = keys.length;
|
---|
266 | let key;
|
---|
267 |
|
---|
268 | for (i = 0; i < len; i++) {
|
---|
269 | key = keys[i];
|
---|
270 | fn.call(null, obj[key], key, obj);
|
---|
271 | }
|
---|
272 | }
|
---|
273 | }
|
---|
274 |
|
---|
275 | function findKey(obj, key) {
|
---|
276 | key = key.toLowerCase();
|
---|
277 | const keys = Object.keys(obj);
|
---|
278 | let i = keys.length;
|
---|
279 | let _key;
|
---|
280 | while (i-- > 0) {
|
---|
281 | _key = keys[i];
|
---|
282 | if (key === _key.toLowerCase()) {
|
---|
283 | return _key;
|
---|
284 | }
|
---|
285 | }
|
---|
286 | return null;
|
---|
287 | }
|
---|
288 |
|
---|
289 | const _global = (() => {
|
---|
290 | /*eslint no-undef:0*/
|
---|
291 | if (typeof globalThis !== "undefined") return globalThis;
|
---|
292 | return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
|
---|
293 | })();
|
---|
294 |
|
---|
295 | const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
---|
296 |
|
---|
297 | /**
|
---|
298 | * Accepts varargs expecting each argument to be an object, then
|
---|
299 | * immutably merges the properties of each object and returns result.
|
---|
300 | *
|
---|
301 | * When multiple objects contain the same key the later object in
|
---|
302 | * the arguments list will take precedence.
|
---|
303 | *
|
---|
304 | * Example:
|
---|
305 | *
|
---|
306 | * ```js
|
---|
307 | * var result = merge({foo: 123}, {foo: 456});
|
---|
308 | * console.log(result.foo); // outputs 456
|
---|
309 | * ```
|
---|
310 | *
|
---|
311 | * @param {Object} obj1 Object to merge
|
---|
312 | *
|
---|
313 | * @returns {Object} Result of all merge properties
|
---|
314 | */
|
---|
315 | function merge(/* obj1, obj2, obj3, ... */) {
|
---|
316 | const {caseless} = isContextDefined(this) && this || {};
|
---|
317 | const result = {};
|
---|
318 | const assignValue = (val, key) => {
|
---|
319 | const targetKey = caseless && findKey(result, key) || key;
|
---|
320 | if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
---|
321 | result[targetKey] = merge(result[targetKey], val);
|
---|
322 | } else if (isPlainObject(val)) {
|
---|
323 | result[targetKey] = merge({}, val);
|
---|
324 | } else if (isArray(val)) {
|
---|
325 | result[targetKey] = val.slice();
|
---|
326 | } else {
|
---|
327 | result[targetKey] = val;
|
---|
328 | }
|
---|
329 | };
|
---|
330 |
|
---|
331 | for (let i = 0, l = arguments.length; i < l; i++) {
|
---|
332 | arguments[i] && forEach(arguments[i], assignValue);
|
---|
333 | }
|
---|
334 | return result;
|
---|
335 | }
|
---|
336 |
|
---|
337 | /**
|
---|
338 | * Extends object a by mutably adding to it the properties of object b.
|
---|
339 | *
|
---|
340 | * @param {Object} a The object to be extended
|
---|
341 | * @param {Object} b The object to copy properties from
|
---|
342 | * @param {Object} thisArg The object to bind function to
|
---|
343 | *
|
---|
344 | * @param {Boolean} [allOwnKeys]
|
---|
345 | * @returns {Object} The resulting value of object a
|
---|
346 | */
|
---|
347 | const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
---|
348 | forEach(b, (val, key) => {
|
---|
349 | if (thisArg && isFunction(val)) {
|
---|
350 | a[key] = bind(val, thisArg);
|
---|
351 | } else {
|
---|
352 | a[key] = val;
|
---|
353 | }
|
---|
354 | }, {allOwnKeys});
|
---|
355 | return a;
|
---|
356 | };
|
---|
357 |
|
---|
358 | /**
|
---|
359 | * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
|
---|
360 | *
|
---|
361 | * @param {string} content with BOM
|
---|
362 | *
|
---|
363 | * @returns {string} content value without BOM
|
---|
364 | */
|
---|
365 | const stripBOM = (content) => {
|
---|
366 | if (content.charCodeAt(0) === 0xFEFF) {
|
---|
367 | content = content.slice(1);
|
---|
368 | }
|
---|
369 | return content;
|
---|
370 | };
|
---|
371 |
|
---|
372 | /**
|
---|
373 | * Inherit the prototype methods from one constructor into another
|
---|
374 | * @param {function} constructor
|
---|
375 | * @param {function} superConstructor
|
---|
376 | * @param {object} [props]
|
---|
377 | * @param {object} [descriptors]
|
---|
378 | *
|
---|
379 | * @returns {void}
|
---|
380 | */
|
---|
381 | const inherits = (constructor, superConstructor, props, descriptors) => {
|
---|
382 | constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
---|
383 | constructor.prototype.constructor = constructor;
|
---|
384 | Object.defineProperty(constructor, 'super', {
|
---|
385 | value: superConstructor.prototype
|
---|
386 | });
|
---|
387 | props && Object.assign(constructor.prototype, props);
|
---|
388 | };
|
---|
389 |
|
---|
390 | /**
|
---|
391 | * Resolve object with deep prototype chain to a flat object
|
---|
392 | * @param {Object} sourceObj source object
|
---|
393 | * @param {Object} [destObj]
|
---|
394 | * @param {Function|Boolean} [filter]
|
---|
395 | * @param {Function} [propFilter]
|
---|
396 | *
|
---|
397 | * @returns {Object}
|
---|
398 | */
|
---|
399 | const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
---|
400 | let props;
|
---|
401 | let i;
|
---|
402 | let prop;
|
---|
403 | const merged = {};
|
---|
404 |
|
---|
405 | destObj = destObj || {};
|
---|
406 | // eslint-disable-next-line no-eq-null,eqeqeq
|
---|
407 | if (sourceObj == null) return destObj;
|
---|
408 |
|
---|
409 | do {
|
---|
410 | props = Object.getOwnPropertyNames(sourceObj);
|
---|
411 | i = props.length;
|
---|
412 | while (i-- > 0) {
|
---|
413 | prop = props[i];
|
---|
414 | if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
---|
415 | destObj[prop] = sourceObj[prop];
|
---|
416 | merged[prop] = true;
|
---|
417 | }
|
---|
418 | }
|
---|
419 | sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
---|
420 | } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
---|
421 |
|
---|
422 | return destObj;
|
---|
423 | };
|
---|
424 |
|
---|
425 | /**
|
---|
426 | * Determines whether a string ends with the characters of a specified string
|
---|
427 | *
|
---|
428 | * @param {String} str
|
---|
429 | * @param {String} searchString
|
---|
430 | * @param {Number} [position= 0]
|
---|
431 | *
|
---|
432 | * @returns {boolean}
|
---|
433 | */
|
---|
434 | const endsWith = (str, searchString, position) => {
|
---|
435 | str = String(str);
|
---|
436 | if (position === undefined || position > str.length) {
|
---|
437 | position = str.length;
|
---|
438 | }
|
---|
439 | position -= searchString.length;
|
---|
440 | const lastIndex = str.indexOf(searchString, position);
|
---|
441 | return lastIndex !== -1 && lastIndex === position;
|
---|
442 | };
|
---|
443 |
|
---|
444 |
|
---|
445 | /**
|
---|
446 | * Returns new array from array like object or null if failed
|
---|
447 | *
|
---|
448 | * @param {*} [thing]
|
---|
449 | *
|
---|
450 | * @returns {?Array}
|
---|
451 | */
|
---|
452 | const toArray = (thing) => {
|
---|
453 | if (!thing) return null;
|
---|
454 | if (isArray(thing)) return thing;
|
---|
455 | let i = thing.length;
|
---|
456 | if (!isNumber(i)) return null;
|
---|
457 | const arr = new Array(i);
|
---|
458 | while (i-- > 0) {
|
---|
459 | arr[i] = thing[i];
|
---|
460 | }
|
---|
461 | return arr;
|
---|
462 | };
|
---|
463 |
|
---|
464 | /**
|
---|
465 | * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
|
---|
466 | * thing passed in is an instance of Uint8Array
|
---|
467 | *
|
---|
468 | * @param {TypedArray}
|
---|
469 | *
|
---|
470 | * @returns {Array}
|
---|
471 | */
|
---|
472 | // eslint-disable-next-line func-names
|
---|
473 | const isTypedArray = (TypedArray => {
|
---|
474 | // eslint-disable-next-line func-names
|
---|
475 | return thing => {
|
---|
476 | return TypedArray && thing instanceof TypedArray;
|
---|
477 | };
|
---|
478 | })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
---|
479 |
|
---|
480 | /**
|
---|
481 | * For each entry in the object, call the function with the key and value.
|
---|
482 | *
|
---|
483 | * @param {Object<any, any>} obj - The object to iterate over.
|
---|
484 | * @param {Function} fn - The function to call for each entry.
|
---|
485 | *
|
---|
486 | * @returns {void}
|
---|
487 | */
|
---|
488 | const forEachEntry = (obj, fn) => {
|
---|
489 | const generator = obj && obj[Symbol.iterator];
|
---|
490 |
|
---|
491 | const iterator = generator.call(obj);
|
---|
492 |
|
---|
493 | let result;
|
---|
494 |
|
---|
495 | while ((result = iterator.next()) && !result.done) {
|
---|
496 | const pair = result.value;
|
---|
497 | fn.call(obj, pair[0], pair[1]);
|
---|
498 | }
|
---|
499 | };
|
---|
500 |
|
---|
501 | /**
|
---|
502 | * It takes a regular expression and a string, and returns an array of all the matches
|
---|
503 | *
|
---|
504 | * @param {string} regExp - The regular expression to match against.
|
---|
505 | * @param {string} str - The string to search.
|
---|
506 | *
|
---|
507 | * @returns {Array<boolean>}
|
---|
508 | */
|
---|
509 | const matchAll = (regExp, str) => {
|
---|
510 | let matches;
|
---|
511 | const arr = [];
|
---|
512 |
|
---|
513 | while ((matches = regExp.exec(str)) !== null) {
|
---|
514 | arr.push(matches);
|
---|
515 | }
|
---|
516 |
|
---|
517 | return arr;
|
---|
518 | };
|
---|
519 |
|
---|
520 | /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
---|
521 | const isHTMLForm = kindOfTest('HTMLFormElement');
|
---|
522 |
|
---|
523 | const toCamelCase = str => {
|
---|
524 | return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
|
---|
525 | function replacer(m, p1, p2) {
|
---|
526 | return p1.toUpperCase() + p2;
|
---|
527 | }
|
---|
528 | );
|
---|
529 | };
|
---|
530 |
|
---|
531 | /* Creating a function that will check if an object has a property. */
|
---|
532 | const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
|
---|
533 |
|
---|
534 | /**
|
---|
535 | * Determine if a value is a RegExp object
|
---|
536 | *
|
---|
537 | * @param {*} val The value to test
|
---|
538 | *
|
---|
539 | * @returns {boolean} True if value is a RegExp object, otherwise false
|
---|
540 | */
|
---|
541 | const isRegExp = kindOfTest('RegExp');
|
---|
542 |
|
---|
543 | const reduceDescriptors = (obj, reducer) => {
|
---|
544 | const descriptors = Object.getOwnPropertyDescriptors(obj);
|
---|
545 | const reducedDescriptors = {};
|
---|
546 |
|
---|
547 | forEach(descriptors, (descriptor, name) => {
|
---|
548 | let ret;
|
---|
549 | if ((ret = reducer(descriptor, name, obj)) !== false) {
|
---|
550 | reducedDescriptors[name] = ret || descriptor;
|
---|
551 | }
|
---|
552 | });
|
---|
553 |
|
---|
554 | Object.defineProperties(obj, reducedDescriptors);
|
---|
555 | };
|
---|
556 |
|
---|
557 | /**
|
---|
558 | * Makes all methods read-only
|
---|
559 | * @param {Object} obj
|
---|
560 | */
|
---|
561 |
|
---|
562 | const freezeMethods = (obj) => {
|
---|
563 | reduceDescriptors(obj, (descriptor, name) => {
|
---|
564 | // skip restricted props in strict mode
|
---|
565 | if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
---|
566 | return false;
|
---|
567 | }
|
---|
568 |
|
---|
569 | const value = obj[name];
|
---|
570 |
|
---|
571 | if (!isFunction(value)) return;
|
---|
572 |
|
---|
573 | descriptor.enumerable = false;
|
---|
574 |
|
---|
575 | if ('writable' in descriptor) {
|
---|
576 | descriptor.writable = false;
|
---|
577 | return;
|
---|
578 | }
|
---|
579 |
|
---|
580 | if (!descriptor.set) {
|
---|
581 | descriptor.set = () => {
|
---|
582 | throw Error('Can not rewrite read-only method \'' + name + '\'');
|
---|
583 | };
|
---|
584 | }
|
---|
585 | });
|
---|
586 | };
|
---|
587 |
|
---|
588 | const toObjectSet = (arrayOrString, delimiter) => {
|
---|
589 | const obj = {};
|
---|
590 |
|
---|
591 | const define = (arr) => {
|
---|
592 | arr.forEach(value => {
|
---|
593 | obj[value] = true;
|
---|
594 | });
|
---|
595 | };
|
---|
596 |
|
---|
597 | isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
---|
598 |
|
---|
599 | return obj;
|
---|
600 | };
|
---|
601 |
|
---|
602 | const noop = () => {};
|
---|
603 |
|
---|
604 | const toFiniteNumber = (value, defaultValue) => {
|
---|
605 | return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
---|
606 | };
|
---|
607 |
|
---|
608 | const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
---|
609 |
|
---|
610 | const DIGIT = '0123456789';
|
---|
611 |
|
---|
612 | const ALPHABET = {
|
---|
613 | DIGIT,
|
---|
614 | ALPHA,
|
---|
615 | ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
---|
616 | };
|
---|
617 |
|
---|
618 | const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
---|
619 | let str = '';
|
---|
620 | const {length} = alphabet;
|
---|
621 | while (size--) {
|
---|
622 | str += alphabet[Math.random() * length|0];
|
---|
623 | }
|
---|
624 |
|
---|
625 | return str;
|
---|
626 | };
|
---|
627 |
|
---|
628 | /**
|
---|
629 | * If the thing is a FormData object, return true, otherwise return false.
|
---|
630 | *
|
---|
631 | * @param {unknown} thing - The thing to check.
|
---|
632 | *
|
---|
633 | * @returns {boolean}
|
---|
634 | */
|
---|
635 | function isSpecCompliantForm(thing) {
|
---|
636 | return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
---|
637 | }
|
---|
638 |
|
---|
639 | const toJSONObject = (obj) => {
|
---|
640 | const stack = new Array(10);
|
---|
641 |
|
---|
642 | const visit = (source, i) => {
|
---|
643 |
|
---|
644 | if (isObject(source)) {
|
---|
645 | if (stack.indexOf(source) >= 0) {
|
---|
646 | return;
|
---|
647 | }
|
---|
648 |
|
---|
649 | if(!('toJSON' in source)) {
|
---|
650 | stack[i] = source;
|
---|
651 | const target = isArray(source) ? [] : {};
|
---|
652 |
|
---|
653 | forEach(source, (value, key) => {
|
---|
654 | const reducedValue = visit(value, i + 1);
|
---|
655 | !isUndefined(reducedValue) && (target[key] = reducedValue);
|
---|
656 | });
|
---|
657 |
|
---|
658 | stack[i] = undefined;
|
---|
659 |
|
---|
660 | return target;
|
---|
661 | }
|
---|
662 | }
|
---|
663 |
|
---|
664 | return source;
|
---|
665 | };
|
---|
666 |
|
---|
667 | return visit(obj, 0);
|
---|
668 | };
|
---|
669 |
|
---|
670 | const isAsyncFn = kindOfTest('AsyncFunction');
|
---|
671 |
|
---|
672 | const isThenable = (thing) =>
|
---|
673 | thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
---|
674 |
|
---|
675 | // original code
|
---|
676 | // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
---|
677 |
|
---|
678 | const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
---|
679 | if (setImmediateSupported) {
|
---|
680 | return setImmediate;
|
---|
681 | }
|
---|
682 |
|
---|
683 | return postMessageSupported ? ((token, callbacks) => {
|
---|
684 | _global.addEventListener("message", ({source, data}) => {
|
---|
685 | if (source === _global && data === token) {
|
---|
686 | callbacks.length && callbacks.shift()();
|
---|
687 | }
|
---|
688 | }, false);
|
---|
689 |
|
---|
690 | return (cb) => {
|
---|
691 | callbacks.push(cb);
|
---|
692 | _global.postMessage(token, "*");
|
---|
693 | }
|
---|
694 | })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
---|
695 | })(
|
---|
696 | typeof setImmediate === 'function',
|
---|
697 | isFunction(_global.postMessage)
|
---|
698 | );
|
---|
699 |
|
---|
700 | const asap = typeof queueMicrotask !== 'undefined' ?
|
---|
701 | queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
|
---|
702 |
|
---|
703 | // *********************
|
---|
704 |
|
---|
705 | const utils$1 = {
|
---|
706 | isArray,
|
---|
707 | isArrayBuffer,
|
---|
708 | isBuffer,
|
---|
709 | isFormData,
|
---|
710 | isArrayBufferView,
|
---|
711 | isString,
|
---|
712 | isNumber,
|
---|
713 | isBoolean,
|
---|
714 | isObject,
|
---|
715 | isPlainObject,
|
---|
716 | isReadableStream,
|
---|
717 | isRequest,
|
---|
718 | isResponse,
|
---|
719 | isHeaders,
|
---|
720 | isUndefined,
|
---|
721 | isDate,
|
---|
722 | isFile,
|
---|
723 | isBlob,
|
---|
724 | isRegExp,
|
---|
725 | isFunction,
|
---|
726 | isStream,
|
---|
727 | isURLSearchParams,
|
---|
728 | isTypedArray,
|
---|
729 | isFileList,
|
---|
730 | forEach,
|
---|
731 | merge,
|
---|
732 | extend,
|
---|
733 | trim,
|
---|
734 | stripBOM,
|
---|
735 | inherits,
|
---|
736 | toFlatObject,
|
---|
737 | kindOf,
|
---|
738 | kindOfTest,
|
---|
739 | endsWith,
|
---|
740 | toArray,
|
---|
741 | forEachEntry,
|
---|
742 | matchAll,
|
---|
743 | isHTMLForm,
|
---|
744 | hasOwnProperty,
|
---|
745 | hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
|
---|
746 | reduceDescriptors,
|
---|
747 | freezeMethods,
|
---|
748 | toObjectSet,
|
---|
749 | toCamelCase,
|
---|
750 | noop,
|
---|
751 | toFiniteNumber,
|
---|
752 | findKey,
|
---|
753 | global: _global,
|
---|
754 | isContextDefined,
|
---|
755 | ALPHABET,
|
---|
756 | generateString,
|
---|
757 | isSpecCompliantForm,
|
---|
758 | toJSONObject,
|
---|
759 | isAsyncFn,
|
---|
760 | isThenable,
|
---|
761 | setImmediate: _setImmediate,
|
---|
762 | asap
|
---|
763 | };
|
---|
764 |
|
---|
765 | /**
|
---|
766 | * Create an Error with the specified message, config, error code, request and response.
|
---|
767 | *
|
---|
768 | * @param {string} message The error message.
|
---|
769 | * @param {string} [code] The error code (for example, 'ECONNABORTED').
|
---|
770 | * @param {Object} [config] The config.
|
---|
771 | * @param {Object} [request] The request.
|
---|
772 | * @param {Object} [response] The response.
|
---|
773 | *
|
---|
774 | * @returns {Error} The created error.
|
---|
775 | */
|
---|
776 | function AxiosError$1(message, code, config, request, response) {
|
---|
777 | Error.call(this);
|
---|
778 |
|
---|
779 | if (Error.captureStackTrace) {
|
---|
780 | Error.captureStackTrace(this, this.constructor);
|
---|
781 | } else {
|
---|
782 | this.stack = (new Error()).stack;
|
---|
783 | }
|
---|
784 |
|
---|
785 | this.message = message;
|
---|
786 | this.name = 'AxiosError';
|
---|
787 | code && (this.code = code);
|
---|
788 | config && (this.config = config);
|
---|
789 | request && (this.request = request);
|
---|
790 | if (response) {
|
---|
791 | this.response = response;
|
---|
792 | this.status = response.status ? response.status : null;
|
---|
793 | }
|
---|
794 | }
|
---|
795 |
|
---|
796 | utils$1.inherits(AxiosError$1, Error, {
|
---|
797 | toJSON: function toJSON() {
|
---|
798 | return {
|
---|
799 | // Standard
|
---|
800 | message: this.message,
|
---|
801 | name: this.name,
|
---|
802 | // Microsoft
|
---|
803 | description: this.description,
|
---|
804 | number: this.number,
|
---|
805 | // Mozilla
|
---|
806 | fileName: this.fileName,
|
---|
807 | lineNumber: this.lineNumber,
|
---|
808 | columnNumber: this.columnNumber,
|
---|
809 | stack: this.stack,
|
---|
810 | // Axios
|
---|
811 | config: utils$1.toJSONObject(this.config),
|
---|
812 | code: this.code,
|
---|
813 | status: this.status
|
---|
814 | };
|
---|
815 | }
|
---|
816 | });
|
---|
817 |
|
---|
818 | const prototype$1 = AxiosError$1.prototype;
|
---|
819 | const descriptors = {};
|
---|
820 |
|
---|
821 | [
|
---|
822 | 'ERR_BAD_OPTION_VALUE',
|
---|
823 | 'ERR_BAD_OPTION',
|
---|
824 | 'ECONNABORTED',
|
---|
825 | 'ETIMEDOUT',
|
---|
826 | 'ERR_NETWORK',
|
---|
827 | 'ERR_FR_TOO_MANY_REDIRECTS',
|
---|
828 | 'ERR_DEPRECATED',
|
---|
829 | 'ERR_BAD_RESPONSE',
|
---|
830 | 'ERR_BAD_REQUEST',
|
---|
831 | 'ERR_CANCELED',
|
---|
832 | 'ERR_NOT_SUPPORT',
|
---|
833 | 'ERR_INVALID_URL'
|
---|
834 | // eslint-disable-next-line func-names
|
---|
835 | ].forEach(code => {
|
---|
836 | descriptors[code] = {value: code};
|
---|
837 | });
|
---|
838 |
|
---|
839 | Object.defineProperties(AxiosError$1, descriptors);
|
---|
840 | Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
---|
841 |
|
---|
842 | // eslint-disable-next-line func-names
|
---|
843 | AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
---|
844 | const axiosError = Object.create(prototype$1);
|
---|
845 |
|
---|
846 | utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
---|
847 | return obj !== Error.prototype;
|
---|
848 | }, prop => {
|
---|
849 | return prop !== 'isAxiosError';
|
---|
850 | });
|
---|
851 |
|
---|
852 | AxiosError$1.call(axiosError, error.message, code, config, request, response);
|
---|
853 |
|
---|
854 | axiosError.cause = error;
|
---|
855 |
|
---|
856 | axiosError.name = error.name;
|
---|
857 |
|
---|
858 | customProps && Object.assign(axiosError, customProps);
|
---|
859 |
|
---|
860 | return axiosError;
|
---|
861 | };
|
---|
862 |
|
---|
863 | // eslint-disable-next-line strict
|
---|
864 | const httpAdapter = null;
|
---|
865 |
|
---|
866 | /**
|
---|
867 | * Determines if the given thing is a array or js object.
|
---|
868 | *
|
---|
869 | * @param {string} thing - The object or array to be visited.
|
---|
870 | *
|
---|
871 | * @returns {boolean}
|
---|
872 | */
|
---|
873 | function isVisitable(thing) {
|
---|
874 | return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
---|
875 | }
|
---|
876 |
|
---|
877 | /**
|
---|
878 | * It removes the brackets from the end of a string
|
---|
879 | *
|
---|
880 | * @param {string} key - The key of the parameter.
|
---|
881 | *
|
---|
882 | * @returns {string} the key without the brackets.
|
---|
883 | */
|
---|
884 | function removeBrackets(key) {
|
---|
885 | return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
---|
886 | }
|
---|
887 |
|
---|
888 | /**
|
---|
889 | * It takes a path, a key, and a boolean, and returns a string
|
---|
890 | *
|
---|
891 | * @param {string} path - The path to the current key.
|
---|
892 | * @param {string} key - The key of the current object being iterated over.
|
---|
893 | * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
---|
894 | *
|
---|
895 | * @returns {string} The path to the current key.
|
---|
896 | */
|
---|
897 | function renderKey(path, key, dots) {
|
---|
898 | if (!path) return key;
|
---|
899 | return path.concat(key).map(function each(token, i) {
|
---|
900 | // eslint-disable-next-line no-param-reassign
|
---|
901 | token = removeBrackets(token);
|
---|
902 | return !dots && i ? '[' + token + ']' : token;
|
---|
903 | }).join(dots ? '.' : '');
|
---|
904 | }
|
---|
905 |
|
---|
906 | /**
|
---|
907 | * If the array is an array and none of its elements are visitable, then it's a flat array.
|
---|
908 | *
|
---|
909 | * @param {Array<any>} arr - The array to check
|
---|
910 | *
|
---|
911 | * @returns {boolean}
|
---|
912 | */
|
---|
913 | function isFlatArray(arr) {
|
---|
914 | return utils$1.isArray(arr) && !arr.some(isVisitable);
|
---|
915 | }
|
---|
916 |
|
---|
917 | const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
---|
918 | return /^is[A-Z]/.test(prop);
|
---|
919 | });
|
---|
920 |
|
---|
921 | /**
|
---|
922 | * Convert a data object to FormData
|
---|
923 | *
|
---|
924 | * @param {Object} obj
|
---|
925 | * @param {?Object} [formData]
|
---|
926 | * @param {?Object} [options]
|
---|
927 | * @param {Function} [options.visitor]
|
---|
928 | * @param {Boolean} [options.metaTokens = true]
|
---|
929 | * @param {Boolean} [options.dots = false]
|
---|
930 | * @param {?Boolean} [options.indexes = false]
|
---|
931 | *
|
---|
932 | * @returns {Object}
|
---|
933 | **/
|
---|
934 |
|
---|
935 | /**
|
---|
936 | * It converts an object into a FormData object
|
---|
937 | *
|
---|
938 | * @param {Object<any, any>} obj - The object to convert to form data.
|
---|
939 | * @param {string} formData - The FormData object to append to.
|
---|
940 | * @param {Object<string, any>} options
|
---|
941 | *
|
---|
942 | * @returns
|
---|
943 | */
|
---|
944 | function toFormData$1(obj, formData, options) {
|
---|
945 | if (!utils$1.isObject(obj)) {
|
---|
946 | throw new TypeError('target must be an object');
|
---|
947 | }
|
---|
948 |
|
---|
949 | // eslint-disable-next-line no-param-reassign
|
---|
950 | formData = formData || new (FormData)();
|
---|
951 |
|
---|
952 | // eslint-disable-next-line no-param-reassign
|
---|
953 | options = utils$1.toFlatObject(options, {
|
---|
954 | metaTokens: true,
|
---|
955 | dots: false,
|
---|
956 | indexes: false
|
---|
957 | }, false, function defined(option, source) {
|
---|
958 | // eslint-disable-next-line no-eq-null,eqeqeq
|
---|
959 | return !utils$1.isUndefined(source[option]);
|
---|
960 | });
|
---|
961 |
|
---|
962 | const metaTokens = options.metaTokens;
|
---|
963 | // eslint-disable-next-line no-use-before-define
|
---|
964 | const visitor = options.visitor || defaultVisitor;
|
---|
965 | const dots = options.dots;
|
---|
966 | const indexes = options.indexes;
|
---|
967 | const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
---|
968 | const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
---|
969 |
|
---|
970 | if (!utils$1.isFunction(visitor)) {
|
---|
971 | throw new TypeError('visitor must be a function');
|
---|
972 | }
|
---|
973 |
|
---|
974 | function convertValue(value) {
|
---|
975 | if (value === null) return '';
|
---|
976 |
|
---|
977 | if (utils$1.isDate(value)) {
|
---|
978 | return value.toISOString();
|
---|
979 | }
|
---|
980 |
|
---|
981 | if (!useBlob && utils$1.isBlob(value)) {
|
---|
982 | throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
---|
983 | }
|
---|
984 |
|
---|
985 | if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
---|
986 | return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
---|
987 | }
|
---|
988 |
|
---|
989 | return value;
|
---|
990 | }
|
---|
991 |
|
---|
992 | /**
|
---|
993 | * Default visitor.
|
---|
994 | *
|
---|
995 | * @param {*} value
|
---|
996 | * @param {String|Number} key
|
---|
997 | * @param {Array<String|Number>} path
|
---|
998 | * @this {FormData}
|
---|
999 | *
|
---|
1000 | * @returns {boolean} return true to visit the each prop of the value recursively
|
---|
1001 | */
|
---|
1002 | function defaultVisitor(value, key, path) {
|
---|
1003 | let arr = value;
|
---|
1004 |
|
---|
1005 | if (value && !path && typeof value === 'object') {
|
---|
1006 | if (utils$1.endsWith(key, '{}')) {
|
---|
1007 | // eslint-disable-next-line no-param-reassign
|
---|
1008 | key = metaTokens ? key : key.slice(0, -2);
|
---|
1009 | // eslint-disable-next-line no-param-reassign
|
---|
1010 | value = JSON.stringify(value);
|
---|
1011 | } else if (
|
---|
1012 | (utils$1.isArray(value) && isFlatArray(value)) ||
|
---|
1013 | ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
---|
1014 | )) {
|
---|
1015 | // eslint-disable-next-line no-param-reassign
|
---|
1016 | key = removeBrackets(key);
|
---|
1017 |
|
---|
1018 | arr.forEach(function each(el, index) {
|
---|
1019 | !(utils$1.isUndefined(el) || el === null) && formData.append(
|
---|
1020 | // eslint-disable-next-line no-nested-ternary
|
---|
1021 | indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
---|
1022 | convertValue(el)
|
---|
1023 | );
|
---|
1024 | });
|
---|
1025 | return false;
|
---|
1026 | }
|
---|
1027 | }
|
---|
1028 |
|
---|
1029 | if (isVisitable(value)) {
|
---|
1030 | return true;
|
---|
1031 | }
|
---|
1032 |
|
---|
1033 | formData.append(renderKey(path, key, dots), convertValue(value));
|
---|
1034 |
|
---|
1035 | return false;
|
---|
1036 | }
|
---|
1037 |
|
---|
1038 | const stack = [];
|
---|
1039 |
|
---|
1040 | const exposedHelpers = Object.assign(predicates, {
|
---|
1041 | defaultVisitor,
|
---|
1042 | convertValue,
|
---|
1043 | isVisitable
|
---|
1044 | });
|
---|
1045 |
|
---|
1046 | function build(value, path) {
|
---|
1047 | if (utils$1.isUndefined(value)) return;
|
---|
1048 |
|
---|
1049 | if (stack.indexOf(value) !== -1) {
|
---|
1050 | throw Error('Circular reference detected in ' + path.join('.'));
|
---|
1051 | }
|
---|
1052 |
|
---|
1053 | stack.push(value);
|
---|
1054 |
|
---|
1055 | utils$1.forEach(value, function each(el, key) {
|
---|
1056 | const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
|
---|
1057 | formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
|
---|
1058 | );
|
---|
1059 |
|
---|
1060 | if (result === true) {
|
---|
1061 | build(el, path ? path.concat(key) : [key]);
|
---|
1062 | }
|
---|
1063 | });
|
---|
1064 |
|
---|
1065 | stack.pop();
|
---|
1066 | }
|
---|
1067 |
|
---|
1068 | if (!utils$1.isObject(obj)) {
|
---|
1069 | throw new TypeError('data must be an object');
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 | build(obj);
|
---|
1073 |
|
---|
1074 | return formData;
|
---|
1075 | }
|
---|
1076 |
|
---|
1077 | /**
|
---|
1078 | * It encodes a string by replacing all characters that are not in the unreserved set with
|
---|
1079 | * their percent-encoded equivalents
|
---|
1080 | *
|
---|
1081 | * @param {string} str - The string to encode.
|
---|
1082 | *
|
---|
1083 | * @returns {string} The encoded string.
|
---|
1084 | */
|
---|
1085 | function encode$1(str) {
|
---|
1086 | const charMap = {
|
---|
1087 | '!': '%21',
|
---|
1088 | "'": '%27',
|
---|
1089 | '(': '%28',
|
---|
1090 | ')': '%29',
|
---|
1091 | '~': '%7E',
|
---|
1092 | '%20': '+',
|
---|
1093 | '%00': '\x00'
|
---|
1094 | };
|
---|
1095 | return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
---|
1096 | return charMap[match];
|
---|
1097 | });
|
---|
1098 | }
|
---|
1099 |
|
---|
1100 | /**
|
---|
1101 | * It takes a params object and converts it to a FormData object
|
---|
1102 | *
|
---|
1103 | * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
---|
1104 | * @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
---|
1105 | *
|
---|
1106 | * @returns {void}
|
---|
1107 | */
|
---|
1108 | function AxiosURLSearchParams(params, options) {
|
---|
1109 | this._pairs = [];
|
---|
1110 |
|
---|
1111 | params && toFormData$1(params, this, options);
|
---|
1112 | }
|
---|
1113 |
|
---|
1114 | const prototype = AxiosURLSearchParams.prototype;
|
---|
1115 |
|
---|
1116 | prototype.append = function append(name, value) {
|
---|
1117 | this._pairs.push([name, value]);
|
---|
1118 | };
|
---|
1119 |
|
---|
1120 | prototype.toString = function toString(encoder) {
|
---|
1121 | const _encode = encoder ? function(value) {
|
---|
1122 | return encoder.call(this, value, encode$1);
|
---|
1123 | } : encode$1;
|
---|
1124 |
|
---|
1125 | return this._pairs.map(function each(pair) {
|
---|
1126 | return _encode(pair[0]) + '=' + _encode(pair[1]);
|
---|
1127 | }, '').join('&');
|
---|
1128 | };
|
---|
1129 |
|
---|
1130 | /**
|
---|
1131 | * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
|
---|
1132 | * URI encoded counterparts
|
---|
1133 | *
|
---|
1134 | * @param {string} val The value to be encoded.
|
---|
1135 | *
|
---|
1136 | * @returns {string} The encoded value.
|
---|
1137 | */
|
---|
1138 | function encode(val) {
|
---|
1139 | return encodeURIComponent(val).
|
---|
1140 | replace(/%3A/gi, ':').
|
---|
1141 | replace(/%24/g, '$').
|
---|
1142 | replace(/%2C/gi, ',').
|
---|
1143 | replace(/%20/g, '+').
|
---|
1144 | replace(/%5B/gi, '[').
|
---|
1145 | replace(/%5D/gi, ']');
|
---|
1146 | }
|
---|
1147 |
|
---|
1148 | /**
|
---|
1149 | * Build a URL by appending params to the end
|
---|
1150 | *
|
---|
1151 | * @param {string} url The base of the url (e.g., http://www.google.com)
|
---|
1152 | * @param {object} [params] The params to be appended
|
---|
1153 | * @param {?object} options
|
---|
1154 | *
|
---|
1155 | * @returns {string} The formatted url
|
---|
1156 | */
|
---|
1157 | function buildURL(url, params, options) {
|
---|
1158 | /*eslint no-param-reassign:0*/
|
---|
1159 | if (!params) {
|
---|
1160 | return url;
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 | const _encode = options && options.encode || encode;
|
---|
1164 |
|
---|
1165 | const serializeFn = options && options.serialize;
|
---|
1166 |
|
---|
1167 | let serializedParams;
|
---|
1168 |
|
---|
1169 | if (serializeFn) {
|
---|
1170 | serializedParams = serializeFn(params, options);
|
---|
1171 | } else {
|
---|
1172 | serializedParams = utils$1.isURLSearchParams(params) ?
|
---|
1173 | params.toString() :
|
---|
1174 | new AxiosURLSearchParams(params, options).toString(_encode);
|
---|
1175 | }
|
---|
1176 |
|
---|
1177 | if (serializedParams) {
|
---|
1178 | const hashmarkIndex = url.indexOf("#");
|
---|
1179 |
|
---|
1180 | if (hashmarkIndex !== -1) {
|
---|
1181 | url = url.slice(0, hashmarkIndex);
|
---|
1182 | }
|
---|
1183 | url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
---|
1184 | }
|
---|
1185 |
|
---|
1186 | return url;
|
---|
1187 | }
|
---|
1188 |
|
---|
1189 | class InterceptorManager {
|
---|
1190 | constructor() {
|
---|
1191 | this.handlers = [];
|
---|
1192 | }
|
---|
1193 |
|
---|
1194 | /**
|
---|
1195 | * Add a new interceptor to the stack
|
---|
1196 | *
|
---|
1197 | * @param {Function} fulfilled The function to handle `then` for a `Promise`
|
---|
1198 | * @param {Function} rejected The function to handle `reject` for a `Promise`
|
---|
1199 | *
|
---|
1200 | * @return {Number} An ID used to remove interceptor later
|
---|
1201 | */
|
---|
1202 | use(fulfilled, rejected, options) {
|
---|
1203 | this.handlers.push({
|
---|
1204 | fulfilled,
|
---|
1205 | rejected,
|
---|
1206 | synchronous: options ? options.synchronous : false,
|
---|
1207 | runWhen: options ? options.runWhen : null
|
---|
1208 | });
|
---|
1209 | return this.handlers.length - 1;
|
---|
1210 | }
|
---|
1211 |
|
---|
1212 | /**
|
---|
1213 | * Remove an interceptor from the stack
|
---|
1214 | *
|
---|
1215 | * @param {Number} id The ID that was returned by `use`
|
---|
1216 | *
|
---|
1217 | * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
---|
1218 | */
|
---|
1219 | eject(id) {
|
---|
1220 | if (this.handlers[id]) {
|
---|
1221 | this.handlers[id] = null;
|
---|
1222 | }
|
---|
1223 | }
|
---|
1224 |
|
---|
1225 | /**
|
---|
1226 | * Clear all interceptors from the stack
|
---|
1227 | *
|
---|
1228 | * @returns {void}
|
---|
1229 | */
|
---|
1230 | clear() {
|
---|
1231 | if (this.handlers) {
|
---|
1232 | this.handlers = [];
|
---|
1233 | }
|
---|
1234 | }
|
---|
1235 |
|
---|
1236 | /**
|
---|
1237 | * Iterate over all the registered interceptors
|
---|
1238 | *
|
---|
1239 | * This method is particularly useful for skipping over any
|
---|
1240 | * interceptors that may have become `null` calling `eject`.
|
---|
1241 | *
|
---|
1242 | * @param {Function} fn The function to call for each interceptor
|
---|
1243 | *
|
---|
1244 | * @returns {void}
|
---|
1245 | */
|
---|
1246 | forEach(fn) {
|
---|
1247 | utils$1.forEach(this.handlers, function forEachHandler(h) {
|
---|
1248 | if (h !== null) {
|
---|
1249 | fn(h);
|
---|
1250 | }
|
---|
1251 | });
|
---|
1252 | }
|
---|
1253 | }
|
---|
1254 |
|
---|
1255 | const InterceptorManager$1 = InterceptorManager;
|
---|
1256 |
|
---|
1257 | const transitionalDefaults = {
|
---|
1258 | silentJSONParsing: true,
|
---|
1259 | forcedJSONParsing: true,
|
---|
1260 | clarifyTimeoutError: false
|
---|
1261 | };
|
---|
1262 |
|
---|
1263 | const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
---|
1264 |
|
---|
1265 | const FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
---|
1266 |
|
---|
1267 | const Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
---|
1268 |
|
---|
1269 | const platform$1 = {
|
---|
1270 | isBrowser: true,
|
---|
1271 | classes: {
|
---|
1272 | URLSearchParams: URLSearchParams$1,
|
---|
1273 | FormData: FormData$1,
|
---|
1274 | Blob: Blob$1
|
---|
1275 | },
|
---|
1276 | protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
---|
1277 | };
|
---|
1278 |
|
---|
1279 | const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
---|
1280 |
|
---|
1281 | const _navigator = typeof navigator === 'object' && navigator || undefined;
|
---|
1282 |
|
---|
1283 | /**
|
---|
1284 | * Determine if we're running in a standard browser environment
|
---|
1285 | *
|
---|
1286 | * This allows axios to run in a web worker, and react-native.
|
---|
1287 | * Both environments support XMLHttpRequest, but not fully standard globals.
|
---|
1288 | *
|
---|
1289 | * web workers:
|
---|
1290 | * typeof window -> undefined
|
---|
1291 | * typeof document -> undefined
|
---|
1292 | *
|
---|
1293 | * react-native:
|
---|
1294 | * navigator.product -> 'ReactNative'
|
---|
1295 | * nativescript
|
---|
1296 | * navigator.product -> 'NativeScript' or 'NS'
|
---|
1297 | *
|
---|
1298 | * @returns {boolean}
|
---|
1299 | */
|
---|
1300 | const hasStandardBrowserEnv = hasBrowserEnv &&
|
---|
1301 | (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
---|
1302 |
|
---|
1303 | /**
|
---|
1304 | * Determine if we're running in a standard browser webWorker environment
|
---|
1305 | *
|
---|
1306 | * Although the `isStandardBrowserEnv` method indicates that
|
---|
1307 | * `allows axios to run in a web worker`, the WebWorker will still be
|
---|
1308 | * filtered out due to its judgment standard
|
---|
1309 | * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
---|
1310 | * This leads to a problem when axios post `FormData` in webWorker
|
---|
1311 | */
|
---|
1312 | const hasStandardBrowserWebWorkerEnv = (() => {
|
---|
1313 | return (
|
---|
1314 | typeof WorkerGlobalScope !== 'undefined' &&
|
---|
1315 | // eslint-disable-next-line no-undef
|
---|
1316 | self instanceof WorkerGlobalScope &&
|
---|
1317 | typeof self.importScripts === 'function'
|
---|
1318 | );
|
---|
1319 | })();
|
---|
1320 |
|
---|
1321 | const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
---|
1322 |
|
---|
1323 | const utils = /*#__PURE__*/Object.freeze({
|
---|
1324 | __proto__: null,
|
---|
1325 | hasBrowserEnv: hasBrowserEnv,
|
---|
1326 | hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
---|
1327 | hasStandardBrowserEnv: hasStandardBrowserEnv,
|
---|
1328 | navigator: _navigator,
|
---|
1329 | origin: origin
|
---|
1330 | });
|
---|
1331 |
|
---|
1332 | const platform = {
|
---|
1333 | ...utils,
|
---|
1334 | ...platform$1
|
---|
1335 | };
|
---|
1336 |
|
---|
1337 | function toURLEncodedForm(data, options) {
|
---|
1338 | return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
|
---|
1339 | visitor: function(value, key, path, helpers) {
|
---|
1340 | if (platform.isNode && utils$1.isBuffer(value)) {
|
---|
1341 | this.append(key, value.toString('base64'));
|
---|
1342 | return false;
|
---|
1343 | }
|
---|
1344 |
|
---|
1345 | return helpers.defaultVisitor.apply(this, arguments);
|
---|
1346 | }
|
---|
1347 | }, options));
|
---|
1348 | }
|
---|
1349 |
|
---|
1350 | /**
|
---|
1351 | * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
---|
1352 | *
|
---|
1353 | * @param {string} name - The name of the property to get.
|
---|
1354 | *
|
---|
1355 | * @returns An array of strings.
|
---|
1356 | */
|
---|
1357 | function parsePropPath(name) {
|
---|
1358 | // foo[x][y][z]
|
---|
1359 | // foo.x.y.z
|
---|
1360 | // foo-x-y-z
|
---|
1361 | // foo x y z
|
---|
1362 | return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
---|
1363 | return match[0] === '[]' ? '' : match[1] || match[0];
|
---|
1364 | });
|
---|
1365 | }
|
---|
1366 |
|
---|
1367 | /**
|
---|
1368 | * Convert an array to an object.
|
---|
1369 | *
|
---|
1370 | * @param {Array<any>} arr - The array to convert to an object.
|
---|
1371 | *
|
---|
1372 | * @returns An object with the same keys and values as the array.
|
---|
1373 | */
|
---|
1374 | function arrayToObject(arr) {
|
---|
1375 | const obj = {};
|
---|
1376 | const keys = Object.keys(arr);
|
---|
1377 | let i;
|
---|
1378 | const len = keys.length;
|
---|
1379 | let key;
|
---|
1380 | for (i = 0; i < len; i++) {
|
---|
1381 | key = keys[i];
|
---|
1382 | obj[key] = arr[key];
|
---|
1383 | }
|
---|
1384 | return obj;
|
---|
1385 | }
|
---|
1386 |
|
---|
1387 | /**
|
---|
1388 | * It takes a FormData object and returns a JavaScript object
|
---|
1389 | *
|
---|
1390 | * @param {string} formData The FormData object to convert to JSON.
|
---|
1391 | *
|
---|
1392 | * @returns {Object<string, any> | null} The converted object.
|
---|
1393 | */
|
---|
1394 | function formDataToJSON(formData) {
|
---|
1395 | function buildPath(path, value, target, index) {
|
---|
1396 | let name = path[index++];
|
---|
1397 |
|
---|
1398 | if (name === '__proto__') return true;
|
---|
1399 |
|
---|
1400 | const isNumericKey = Number.isFinite(+name);
|
---|
1401 | const isLast = index >= path.length;
|
---|
1402 | name = !name && utils$1.isArray(target) ? target.length : name;
|
---|
1403 |
|
---|
1404 | if (isLast) {
|
---|
1405 | if (utils$1.hasOwnProp(target, name)) {
|
---|
1406 | target[name] = [target[name], value];
|
---|
1407 | } else {
|
---|
1408 | target[name] = value;
|
---|
1409 | }
|
---|
1410 |
|
---|
1411 | return !isNumericKey;
|
---|
1412 | }
|
---|
1413 |
|
---|
1414 | if (!target[name] || !utils$1.isObject(target[name])) {
|
---|
1415 | target[name] = [];
|
---|
1416 | }
|
---|
1417 |
|
---|
1418 | const result = buildPath(path, value, target[name], index);
|
---|
1419 |
|
---|
1420 | if (result && utils$1.isArray(target[name])) {
|
---|
1421 | target[name] = arrayToObject(target[name]);
|
---|
1422 | }
|
---|
1423 |
|
---|
1424 | return !isNumericKey;
|
---|
1425 | }
|
---|
1426 |
|
---|
1427 | if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
---|
1428 | const obj = {};
|
---|
1429 |
|
---|
1430 | utils$1.forEachEntry(formData, (name, value) => {
|
---|
1431 | buildPath(parsePropPath(name), value, obj, 0);
|
---|
1432 | });
|
---|
1433 |
|
---|
1434 | return obj;
|
---|
1435 | }
|
---|
1436 |
|
---|
1437 | return null;
|
---|
1438 | }
|
---|
1439 |
|
---|
1440 | /**
|
---|
1441 | * It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
---|
1442 | * of the input
|
---|
1443 | *
|
---|
1444 | * @param {any} rawValue - The value to be stringified.
|
---|
1445 | * @param {Function} parser - A function that parses a string into a JavaScript object.
|
---|
1446 | * @param {Function} encoder - A function that takes a value and returns a string.
|
---|
1447 | *
|
---|
1448 | * @returns {string} A stringified version of the rawValue.
|
---|
1449 | */
|
---|
1450 | function stringifySafely(rawValue, parser, encoder) {
|
---|
1451 | if (utils$1.isString(rawValue)) {
|
---|
1452 | try {
|
---|
1453 | (parser || JSON.parse)(rawValue);
|
---|
1454 | return utils$1.trim(rawValue);
|
---|
1455 | } catch (e) {
|
---|
1456 | if (e.name !== 'SyntaxError') {
|
---|
1457 | throw e;
|
---|
1458 | }
|
---|
1459 | }
|
---|
1460 | }
|
---|
1461 |
|
---|
1462 | return (encoder || JSON.stringify)(rawValue);
|
---|
1463 | }
|
---|
1464 |
|
---|
1465 | const defaults = {
|
---|
1466 |
|
---|
1467 | transitional: transitionalDefaults,
|
---|
1468 |
|
---|
1469 | adapter: ['xhr', 'http', 'fetch'],
|
---|
1470 |
|
---|
1471 | transformRequest: [function transformRequest(data, headers) {
|
---|
1472 | const contentType = headers.getContentType() || '';
|
---|
1473 | const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
---|
1474 | const isObjectPayload = utils$1.isObject(data);
|
---|
1475 |
|
---|
1476 | if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
---|
1477 | data = new FormData(data);
|
---|
1478 | }
|
---|
1479 |
|
---|
1480 | const isFormData = utils$1.isFormData(data);
|
---|
1481 |
|
---|
1482 | if (isFormData) {
|
---|
1483 | return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
---|
1484 | }
|
---|
1485 |
|
---|
1486 | if (utils$1.isArrayBuffer(data) ||
|
---|
1487 | utils$1.isBuffer(data) ||
|
---|
1488 | utils$1.isStream(data) ||
|
---|
1489 | utils$1.isFile(data) ||
|
---|
1490 | utils$1.isBlob(data) ||
|
---|
1491 | utils$1.isReadableStream(data)
|
---|
1492 | ) {
|
---|
1493 | return data;
|
---|
1494 | }
|
---|
1495 | if (utils$1.isArrayBufferView(data)) {
|
---|
1496 | return data.buffer;
|
---|
1497 | }
|
---|
1498 | if (utils$1.isURLSearchParams(data)) {
|
---|
1499 | headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
---|
1500 | return data.toString();
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 | let isFileList;
|
---|
1504 |
|
---|
1505 | if (isObjectPayload) {
|
---|
1506 | if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
---|
1507 | return toURLEncodedForm(data, this.formSerializer).toString();
|
---|
1508 | }
|
---|
1509 |
|
---|
1510 | if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
---|
1511 | const _FormData = this.env && this.env.FormData;
|
---|
1512 |
|
---|
1513 | return toFormData$1(
|
---|
1514 | isFileList ? {'files[]': data} : data,
|
---|
1515 | _FormData && new _FormData(),
|
---|
1516 | this.formSerializer
|
---|
1517 | );
|
---|
1518 | }
|
---|
1519 | }
|
---|
1520 |
|
---|
1521 | if (isObjectPayload || hasJSONContentType ) {
|
---|
1522 | headers.setContentType('application/json', false);
|
---|
1523 | return stringifySafely(data);
|
---|
1524 | }
|
---|
1525 |
|
---|
1526 | return data;
|
---|
1527 | }],
|
---|
1528 |
|
---|
1529 | transformResponse: [function transformResponse(data) {
|
---|
1530 | const transitional = this.transitional || defaults.transitional;
|
---|
1531 | const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
---|
1532 | const JSONRequested = this.responseType === 'json';
|
---|
1533 |
|
---|
1534 | if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
---|
1535 | return data;
|
---|
1536 | }
|
---|
1537 |
|
---|
1538 | if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
---|
1539 | const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
---|
1540 | const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
---|
1541 |
|
---|
1542 | try {
|
---|
1543 | return JSON.parse(data);
|
---|
1544 | } catch (e) {
|
---|
1545 | if (strictJSONParsing) {
|
---|
1546 | if (e.name === 'SyntaxError') {
|
---|
1547 | throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
---|
1548 | }
|
---|
1549 | throw e;
|
---|
1550 | }
|
---|
1551 | }
|
---|
1552 | }
|
---|
1553 |
|
---|
1554 | return data;
|
---|
1555 | }],
|
---|
1556 |
|
---|
1557 | /**
|
---|
1558 | * A timeout in milliseconds to abort a request. If set to 0 (default) a
|
---|
1559 | * timeout is not created.
|
---|
1560 | */
|
---|
1561 | timeout: 0,
|
---|
1562 |
|
---|
1563 | xsrfCookieName: 'XSRF-TOKEN',
|
---|
1564 | xsrfHeaderName: 'X-XSRF-TOKEN',
|
---|
1565 |
|
---|
1566 | maxContentLength: -1,
|
---|
1567 | maxBodyLength: -1,
|
---|
1568 |
|
---|
1569 | env: {
|
---|
1570 | FormData: platform.classes.FormData,
|
---|
1571 | Blob: platform.classes.Blob
|
---|
1572 | },
|
---|
1573 |
|
---|
1574 | validateStatus: function validateStatus(status) {
|
---|
1575 | return status >= 200 && status < 300;
|
---|
1576 | },
|
---|
1577 |
|
---|
1578 | headers: {
|
---|
1579 | common: {
|
---|
1580 | 'Accept': 'application/json, text/plain, */*',
|
---|
1581 | 'Content-Type': undefined
|
---|
1582 | }
|
---|
1583 | }
|
---|
1584 | };
|
---|
1585 |
|
---|
1586 | utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
---|
1587 | defaults.headers[method] = {};
|
---|
1588 | });
|
---|
1589 |
|
---|
1590 | const defaults$1 = defaults;
|
---|
1591 |
|
---|
1592 | // RawAxiosHeaders whose duplicates are ignored by node
|
---|
1593 | // c.f. https://nodejs.org/api/http.html#http_message_headers
|
---|
1594 | const ignoreDuplicateOf = utils$1.toObjectSet([
|
---|
1595 | 'age', 'authorization', 'content-length', 'content-type', 'etag',
|
---|
1596 | 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
---|
1597 | 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
---|
1598 | 'referer', 'retry-after', 'user-agent'
|
---|
1599 | ]);
|
---|
1600 |
|
---|
1601 | /**
|
---|
1602 | * Parse headers into an object
|
---|
1603 | *
|
---|
1604 | * ```
|
---|
1605 | * Date: Wed, 27 Aug 2014 08:58:49 GMT
|
---|
1606 | * Content-Type: application/json
|
---|
1607 | * Connection: keep-alive
|
---|
1608 | * Transfer-Encoding: chunked
|
---|
1609 | * ```
|
---|
1610 | *
|
---|
1611 | * @param {String} rawHeaders Headers needing to be parsed
|
---|
1612 | *
|
---|
1613 | * @returns {Object} Headers parsed into an object
|
---|
1614 | */
|
---|
1615 | const parseHeaders = rawHeaders => {
|
---|
1616 | const parsed = {};
|
---|
1617 | let key;
|
---|
1618 | let val;
|
---|
1619 | let i;
|
---|
1620 |
|
---|
1621 | rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
|
---|
1622 | i = line.indexOf(':');
|
---|
1623 | key = line.substring(0, i).trim().toLowerCase();
|
---|
1624 | val = line.substring(i + 1).trim();
|
---|
1625 |
|
---|
1626 | if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
---|
1627 | return;
|
---|
1628 | }
|
---|
1629 |
|
---|
1630 | if (key === 'set-cookie') {
|
---|
1631 | if (parsed[key]) {
|
---|
1632 | parsed[key].push(val);
|
---|
1633 | } else {
|
---|
1634 | parsed[key] = [val];
|
---|
1635 | }
|
---|
1636 | } else {
|
---|
1637 | parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
---|
1638 | }
|
---|
1639 | });
|
---|
1640 |
|
---|
1641 | return parsed;
|
---|
1642 | };
|
---|
1643 |
|
---|
1644 | const $internals = Symbol('internals');
|
---|
1645 |
|
---|
1646 | function normalizeHeader(header) {
|
---|
1647 | return header && String(header).trim().toLowerCase();
|
---|
1648 | }
|
---|
1649 |
|
---|
1650 | function normalizeValue(value) {
|
---|
1651 | if (value === false || value == null) {
|
---|
1652 | return value;
|
---|
1653 | }
|
---|
1654 |
|
---|
1655 | return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
---|
1656 | }
|
---|
1657 |
|
---|
1658 | function parseTokens(str) {
|
---|
1659 | const tokens = Object.create(null);
|
---|
1660 | const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
---|
1661 | let match;
|
---|
1662 |
|
---|
1663 | while ((match = tokensRE.exec(str))) {
|
---|
1664 | tokens[match[1]] = match[2];
|
---|
1665 | }
|
---|
1666 |
|
---|
1667 | return tokens;
|
---|
1668 | }
|
---|
1669 |
|
---|
1670 | const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
---|
1671 |
|
---|
1672 | function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
---|
1673 | if (utils$1.isFunction(filter)) {
|
---|
1674 | return filter.call(this, value, header);
|
---|
1675 | }
|
---|
1676 |
|
---|
1677 | if (isHeaderNameFilter) {
|
---|
1678 | value = header;
|
---|
1679 | }
|
---|
1680 |
|
---|
1681 | if (!utils$1.isString(value)) return;
|
---|
1682 |
|
---|
1683 | if (utils$1.isString(filter)) {
|
---|
1684 | return value.indexOf(filter) !== -1;
|
---|
1685 | }
|
---|
1686 |
|
---|
1687 | if (utils$1.isRegExp(filter)) {
|
---|
1688 | return filter.test(value);
|
---|
1689 | }
|
---|
1690 | }
|
---|
1691 |
|
---|
1692 | function formatHeader(header) {
|
---|
1693 | return header.trim()
|
---|
1694 | .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
---|
1695 | return char.toUpperCase() + str;
|
---|
1696 | });
|
---|
1697 | }
|
---|
1698 |
|
---|
1699 | function buildAccessors(obj, header) {
|
---|
1700 | const accessorName = utils$1.toCamelCase(' ' + header);
|
---|
1701 |
|
---|
1702 | ['get', 'set', 'has'].forEach(methodName => {
|
---|
1703 | Object.defineProperty(obj, methodName + accessorName, {
|
---|
1704 | value: function(arg1, arg2, arg3) {
|
---|
1705 | return this[methodName].call(this, header, arg1, arg2, arg3);
|
---|
1706 | },
|
---|
1707 | configurable: true
|
---|
1708 | });
|
---|
1709 | });
|
---|
1710 | }
|
---|
1711 |
|
---|
1712 | class AxiosHeaders$1 {
|
---|
1713 | constructor(headers) {
|
---|
1714 | headers && this.set(headers);
|
---|
1715 | }
|
---|
1716 |
|
---|
1717 | set(header, valueOrRewrite, rewrite) {
|
---|
1718 | const self = this;
|
---|
1719 |
|
---|
1720 | function setHeader(_value, _header, _rewrite) {
|
---|
1721 | const lHeader = normalizeHeader(_header);
|
---|
1722 |
|
---|
1723 | if (!lHeader) {
|
---|
1724 | throw new Error('header name must be a non-empty string');
|
---|
1725 | }
|
---|
1726 |
|
---|
1727 | const key = utils$1.findKey(self, lHeader);
|
---|
1728 |
|
---|
1729 | if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
---|
1730 | self[key || _header] = normalizeValue(_value);
|
---|
1731 | }
|
---|
1732 | }
|
---|
1733 |
|
---|
1734 | const setHeaders = (headers, _rewrite) =>
|
---|
1735 | utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
---|
1736 |
|
---|
1737 | if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
---|
1738 | setHeaders(header, valueOrRewrite);
|
---|
1739 | } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
---|
1740 | setHeaders(parseHeaders(header), valueOrRewrite);
|
---|
1741 | } else if (utils$1.isHeaders(header)) {
|
---|
1742 | for (const [key, value] of header.entries()) {
|
---|
1743 | setHeader(value, key, rewrite);
|
---|
1744 | }
|
---|
1745 | } else {
|
---|
1746 | header != null && setHeader(valueOrRewrite, header, rewrite);
|
---|
1747 | }
|
---|
1748 |
|
---|
1749 | return this;
|
---|
1750 | }
|
---|
1751 |
|
---|
1752 | get(header, parser) {
|
---|
1753 | header = normalizeHeader(header);
|
---|
1754 |
|
---|
1755 | if (header) {
|
---|
1756 | const key = utils$1.findKey(this, header);
|
---|
1757 |
|
---|
1758 | if (key) {
|
---|
1759 | const value = this[key];
|
---|
1760 |
|
---|
1761 | if (!parser) {
|
---|
1762 | return value;
|
---|
1763 | }
|
---|
1764 |
|
---|
1765 | if (parser === true) {
|
---|
1766 | return parseTokens(value);
|
---|
1767 | }
|
---|
1768 |
|
---|
1769 | if (utils$1.isFunction(parser)) {
|
---|
1770 | return parser.call(this, value, key);
|
---|
1771 | }
|
---|
1772 |
|
---|
1773 | if (utils$1.isRegExp(parser)) {
|
---|
1774 | return parser.exec(value);
|
---|
1775 | }
|
---|
1776 |
|
---|
1777 | throw new TypeError('parser must be boolean|regexp|function');
|
---|
1778 | }
|
---|
1779 | }
|
---|
1780 | }
|
---|
1781 |
|
---|
1782 | has(header, matcher) {
|
---|
1783 | header = normalizeHeader(header);
|
---|
1784 |
|
---|
1785 | if (header) {
|
---|
1786 | const key = utils$1.findKey(this, header);
|
---|
1787 |
|
---|
1788 | return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
---|
1789 | }
|
---|
1790 |
|
---|
1791 | return false;
|
---|
1792 | }
|
---|
1793 |
|
---|
1794 | delete(header, matcher) {
|
---|
1795 | const self = this;
|
---|
1796 | let deleted = false;
|
---|
1797 |
|
---|
1798 | function deleteHeader(_header) {
|
---|
1799 | _header = normalizeHeader(_header);
|
---|
1800 |
|
---|
1801 | if (_header) {
|
---|
1802 | const key = utils$1.findKey(self, _header);
|
---|
1803 |
|
---|
1804 | if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
---|
1805 | delete self[key];
|
---|
1806 |
|
---|
1807 | deleted = true;
|
---|
1808 | }
|
---|
1809 | }
|
---|
1810 | }
|
---|
1811 |
|
---|
1812 | if (utils$1.isArray(header)) {
|
---|
1813 | header.forEach(deleteHeader);
|
---|
1814 | } else {
|
---|
1815 | deleteHeader(header);
|
---|
1816 | }
|
---|
1817 |
|
---|
1818 | return deleted;
|
---|
1819 | }
|
---|
1820 |
|
---|
1821 | clear(matcher) {
|
---|
1822 | const keys = Object.keys(this);
|
---|
1823 | let i = keys.length;
|
---|
1824 | let deleted = false;
|
---|
1825 |
|
---|
1826 | while (i--) {
|
---|
1827 | const key = keys[i];
|
---|
1828 | if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
---|
1829 | delete this[key];
|
---|
1830 | deleted = true;
|
---|
1831 | }
|
---|
1832 | }
|
---|
1833 |
|
---|
1834 | return deleted;
|
---|
1835 | }
|
---|
1836 |
|
---|
1837 | normalize(format) {
|
---|
1838 | const self = this;
|
---|
1839 | const headers = {};
|
---|
1840 |
|
---|
1841 | utils$1.forEach(this, (value, header) => {
|
---|
1842 | const key = utils$1.findKey(headers, header);
|
---|
1843 |
|
---|
1844 | if (key) {
|
---|
1845 | self[key] = normalizeValue(value);
|
---|
1846 | delete self[header];
|
---|
1847 | return;
|
---|
1848 | }
|
---|
1849 |
|
---|
1850 | const normalized = format ? formatHeader(header) : String(header).trim();
|
---|
1851 |
|
---|
1852 | if (normalized !== header) {
|
---|
1853 | delete self[header];
|
---|
1854 | }
|
---|
1855 |
|
---|
1856 | self[normalized] = normalizeValue(value);
|
---|
1857 |
|
---|
1858 | headers[normalized] = true;
|
---|
1859 | });
|
---|
1860 |
|
---|
1861 | return this;
|
---|
1862 | }
|
---|
1863 |
|
---|
1864 | concat(...targets) {
|
---|
1865 | return this.constructor.concat(this, ...targets);
|
---|
1866 | }
|
---|
1867 |
|
---|
1868 | toJSON(asStrings) {
|
---|
1869 | const obj = Object.create(null);
|
---|
1870 |
|
---|
1871 | utils$1.forEach(this, (value, header) => {
|
---|
1872 | value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
---|
1873 | });
|
---|
1874 |
|
---|
1875 | return obj;
|
---|
1876 | }
|
---|
1877 |
|
---|
1878 | [Symbol.iterator]() {
|
---|
1879 | return Object.entries(this.toJSON())[Symbol.iterator]();
|
---|
1880 | }
|
---|
1881 |
|
---|
1882 | toString() {
|
---|
1883 | return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
---|
1884 | }
|
---|
1885 |
|
---|
1886 | get [Symbol.toStringTag]() {
|
---|
1887 | return 'AxiosHeaders';
|
---|
1888 | }
|
---|
1889 |
|
---|
1890 | static from(thing) {
|
---|
1891 | return thing instanceof this ? thing : new this(thing);
|
---|
1892 | }
|
---|
1893 |
|
---|
1894 | static concat(first, ...targets) {
|
---|
1895 | const computed = new this(first);
|
---|
1896 |
|
---|
1897 | targets.forEach((target) => computed.set(target));
|
---|
1898 |
|
---|
1899 | return computed;
|
---|
1900 | }
|
---|
1901 |
|
---|
1902 | static accessor(header) {
|
---|
1903 | const internals = this[$internals] = (this[$internals] = {
|
---|
1904 | accessors: {}
|
---|
1905 | });
|
---|
1906 |
|
---|
1907 | const accessors = internals.accessors;
|
---|
1908 | const prototype = this.prototype;
|
---|
1909 |
|
---|
1910 | function defineAccessor(_header) {
|
---|
1911 | const lHeader = normalizeHeader(_header);
|
---|
1912 |
|
---|
1913 | if (!accessors[lHeader]) {
|
---|
1914 | buildAccessors(prototype, _header);
|
---|
1915 | accessors[lHeader] = true;
|
---|
1916 | }
|
---|
1917 | }
|
---|
1918 |
|
---|
1919 | utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
---|
1920 |
|
---|
1921 | return this;
|
---|
1922 | }
|
---|
1923 | }
|
---|
1924 |
|
---|
1925 | AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
---|
1926 |
|
---|
1927 | // reserved names hotfix
|
---|
1928 | utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
|
---|
1929 | let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
---|
1930 | return {
|
---|
1931 | get: () => value,
|
---|
1932 | set(headerValue) {
|
---|
1933 | this[mapped] = headerValue;
|
---|
1934 | }
|
---|
1935 | }
|
---|
1936 | });
|
---|
1937 |
|
---|
1938 | utils$1.freezeMethods(AxiosHeaders$1);
|
---|
1939 |
|
---|
1940 | const AxiosHeaders$2 = AxiosHeaders$1;
|
---|
1941 |
|
---|
1942 | /**
|
---|
1943 | * Transform the data for a request or a response
|
---|
1944 | *
|
---|
1945 | * @param {Array|Function} fns A single function or Array of functions
|
---|
1946 | * @param {?Object} response The response object
|
---|
1947 | *
|
---|
1948 | * @returns {*} The resulting transformed data
|
---|
1949 | */
|
---|
1950 | function transformData(fns, response) {
|
---|
1951 | const config = this || defaults$1;
|
---|
1952 | const context = response || config;
|
---|
1953 | const headers = AxiosHeaders$2.from(context.headers);
|
---|
1954 | let data = context.data;
|
---|
1955 |
|
---|
1956 | utils$1.forEach(fns, function transform(fn) {
|
---|
1957 | data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
---|
1958 | });
|
---|
1959 |
|
---|
1960 | headers.normalize();
|
---|
1961 |
|
---|
1962 | return data;
|
---|
1963 | }
|
---|
1964 |
|
---|
1965 | function isCancel$1(value) {
|
---|
1966 | return !!(value && value.__CANCEL__);
|
---|
1967 | }
|
---|
1968 |
|
---|
1969 | /**
|
---|
1970 | * A `CanceledError` is an object that is thrown when an operation is canceled.
|
---|
1971 | *
|
---|
1972 | * @param {string=} message The message.
|
---|
1973 | * @param {Object=} config The config.
|
---|
1974 | * @param {Object=} request The request.
|
---|
1975 | *
|
---|
1976 | * @returns {CanceledError} The created error.
|
---|
1977 | */
|
---|
1978 | function CanceledError$1(message, config, request) {
|
---|
1979 | // eslint-disable-next-line no-eq-null,eqeqeq
|
---|
1980 | AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
---|
1981 | this.name = 'CanceledError';
|
---|
1982 | }
|
---|
1983 |
|
---|
1984 | utils$1.inherits(CanceledError$1, AxiosError$1, {
|
---|
1985 | __CANCEL__: true
|
---|
1986 | });
|
---|
1987 |
|
---|
1988 | /**
|
---|
1989 | * Resolve or reject a Promise based on response status.
|
---|
1990 | *
|
---|
1991 | * @param {Function} resolve A function that resolves the promise.
|
---|
1992 | * @param {Function} reject A function that rejects the promise.
|
---|
1993 | * @param {object} response The response.
|
---|
1994 | *
|
---|
1995 | * @returns {object} The response.
|
---|
1996 | */
|
---|
1997 | function settle(resolve, reject, response) {
|
---|
1998 | const validateStatus = response.config.validateStatus;
|
---|
1999 | if (!response.status || !validateStatus || validateStatus(response.status)) {
|
---|
2000 | resolve(response);
|
---|
2001 | } else {
|
---|
2002 | reject(new AxiosError$1(
|
---|
2003 | 'Request failed with status code ' + response.status,
|
---|
2004 | [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
---|
2005 | response.config,
|
---|
2006 | response.request,
|
---|
2007 | response
|
---|
2008 | ));
|
---|
2009 | }
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | function parseProtocol(url) {
|
---|
2013 | const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
---|
2014 | return match && match[1] || '';
|
---|
2015 | }
|
---|
2016 |
|
---|
2017 | /**
|
---|
2018 | * Calculate data maxRate
|
---|
2019 | * @param {Number} [samplesCount= 10]
|
---|
2020 | * @param {Number} [min= 1000]
|
---|
2021 | * @returns {Function}
|
---|
2022 | */
|
---|
2023 | function speedometer(samplesCount, min) {
|
---|
2024 | samplesCount = samplesCount || 10;
|
---|
2025 | const bytes = new Array(samplesCount);
|
---|
2026 | const timestamps = new Array(samplesCount);
|
---|
2027 | let head = 0;
|
---|
2028 | let tail = 0;
|
---|
2029 | let firstSampleTS;
|
---|
2030 |
|
---|
2031 | min = min !== undefined ? min : 1000;
|
---|
2032 |
|
---|
2033 | return function push(chunkLength) {
|
---|
2034 | const now = Date.now();
|
---|
2035 |
|
---|
2036 | const startedAt = timestamps[tail];
|
---|
2037 |
|
---|
2038 | if (!firstSampleTS) {
|
---|
2039 | firstSampleTS = now;
|
---|
2040 | }
|
---|
2041 |
|
---|
2042 | bytes[head] = chunkLength;
|
---|
2043 | timestamps[head] = now;
|
---|
2044 |
|
---|
2045 | let i = tail;
|
---|
2046 | let bytesCount = 0;
|
---|
2047 |
|
---|
2048 | while (i !== head) {
|
---|
2049 | bytesCount += bytes[i++];
|
---|
2050 | i = i % samplesCount;
|
---|
2051 | }
|
---|
2052 |
|
---|
2053 | head = (head + 1) % samplesCount;
|
---|
2054 |
|
---|
2055 | if (head === tail) {
|
---|
2056 | tail = (tail + 1) % samplesCount;
|
---|
2057 | }
|
---|
2058 |
|
---|
2059 | if (now - firstSampleTS < min) {
|
---|
2060 | return;
|
---|
2061 | }
|
---|
2062 |
|
---|
2063 | const passed = startedAt && now - startedAt;
|
---|
2064 |
|
---|
2065 | return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
---|
2066 | };
|
---|
2067 | }
|
---|
2068 |
|
---|
2069 | /**
|
---|
2070 | * Throttle decorator
|
---|
2071 | * @param {Function} fn
|
---|
2072 | * @param {Number} freq
|
---|
2073 | * @return {Function}
|
---|
2074 | */
|
---|
2075 | function throttle(fn, freq) {
|
---|
2076 | let timestamp = 0;
|
---|
2077 | let threshold = 1000 / freq;
|
---|
2078 | let lastArgs;
|
---|
2079 | let timer;
|
---|
2080 |
|
---|
2081 | const invoke = (args, now = Date.now()) => {
|
---|
2082 | timestamp = now;
|
---|
2083 | lastArgs = null;
|
---|
2084 | if (timer) {
|
---|
2085 | clearTimeout(timer);
|
---|
2086 | timer = null;
|
---|
2087 | }
|
---|
2088 | fn.apply(null, args);
|
---|
2089 | };
|
---|
2090 |
|
---|
2091 | const throttled = (...args) => {
|
---|
2092 | const now = Date.now();
|
---|
2093 | const passed = now - timestamp;
|
---|
2094 | if ( passed >= threshold) {
|
---|
2095 | invoke(args, now);
|
---|
2096 | } else {
|
---|
2097 | lastArgs = args;
|
---|
2098 | if (!timer) {
|
---|
2099 | timer = setTimeout(() => {
|
---|
2100 | timer = null;
|
---|
2101 | invoke(lastArgs);
|
---|
2102 | }, threshold - passed);
|
---|
2103 | }
|
---|
2104 | }
|
---|
2105 | };
|
---|
2106 |
|
---|
2107 | const flush = () => lastArgs && invoke(lastArgs);
|
---|
2108 |
|
---|
2109 | return [throttled, flush];
|
---|
2110 | }
|
---|
2111 |
|
---|
2112 | const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
---|
2113 | let bytesNotified = 0;
|
---|
2114 | const _speedometer = speedometer(50, 250);
|
---|
2115 |
|
---|
2116 | return throttle(e => {
|
---|
2117 | const loaded = e.loaded;
|
---|
2118 | const total = e.lengthComputable ? e.total : undefined;
|
---|
2119 | const progressBytes = loaded - bytesNotified;
|
---|
2120 | const rate = _speedometer(progressBytes);
|
---|
2121 | const inRange = loaded <= total;
|
---|
2122 |
|
---|
2123 | bytesNotified = loaded;
|
---|
2124 |
|
---|
2125 | const data = {
|
---|
2126 | loaded,
|
---|
2127 | total,
|
---|
2128 | progress: total ? (loaded / total) : undefined,
|
---|
2129 | bytes: progressBytes,
|
---|
2130 | rate: rate ? rate : undefined,
|
---|
2131 | estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
---|
2132 | event: e,
|
---|
2133 | lengthComputable: total != null,
|
---|
2134 | [isDownloadStream ? 'download' : 'upload']: true
|
---|
2135 | };
|
---|
2136 |
|
---|
2137 | listener(data);
|
---|
2138 | }, freq);
|
---|
2139 | };
|
---|
2140 |
|
---|
2141 | const progressEventDecorator = (total, throttled) => {
|
---|
2142 | const lengthComputable = total != null;
|
---|
2143 |
|
---|
2144 | return [(loaded) => throttled[0]({
|
---|
2145 | lengthComputable,
|
---|
2146 | total,
|
---|
2147 | loaded
|
---|
2148 | }), throttled[1]];
|
---|
2149 | };
|
---|
2150 |
|
---|
2151 | const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
---|
2152 |
|
---|
2153 | const isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
---|
2154 |
|
---|
2155 | // Standard browser envs have full support of the APIs needed to test
|
---|
2156 | // whether the request URL is of the same origin as current location.
|
---|
2157 | (function standardBrowserEnv() {
|
---|
2158 | const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
|
---|
2159 | const urlParsingNode = document.createElement('a');
|
---|
2160 | let originURL;
|
---|
2161 |
|
---|
2162 | /**
|
---|
2163 | * Parse a URL to discover its components
|
---|
2164 | *
|
---|
2165 | * @param {String} url The URL to be parsed
|
---|
2166 | * @returns {Object}
|
---|
2167 | */
|
---|
2168 | function resolveURL(url) {
|
---|
2169 | let href = url;
|
---|
2170 |
|
---|
2171 | if (msie) {
|
---|
2172 | // IE needs attribute set twice to normalize properties
|
---|
2173 | urlParsingNode.setAttribute('href', href);
|
---|
2174 | href = urlParsingNode.href;
|
---|
2175 | }
|
---|
2176 |
|
---|
2177 | urlParsingNode.setAttribute('href', href);
|
---|
2178 |
|
---|
2179 | // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
---|
2180 | return {
|
---|
2181 | href: urlParsingNode.href,
|
---|
2182 | protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
---|
2183 | host: urlParsingNode.host,
|
---|
2184 | search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
---|
2185 | hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
---|
2186 | hostname: urlParsingNode.hostname,
|
---|
2187 | port: urlParsingNode.port,
|
---|
2188 | pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
---|
2189 | urlParsingNode.pathname :
|
---|
2190 | '/' + urlParsingNode.pathname
|
---|
2191 | };
|
---|
2192 | }
|
---|
2193 |
|
---|
2194 | originURL = resolveURL(window.location.href);
|
---|
2195 |
|
---|
2196 | /**
|
---|
2197 | * Determine if a URL shares the same origin as the current location
|
---|
2198 | *
|
---|
2199 | * @param {String} requestURL The URL to test
|
---|
2200 | * @returns {boolean} True if URL shares the same origin, otherwise false
|
---|
2201 | */
|
---|
2202 | return function isURLSameOrigin(requestURL) {
|
---|
2203 | const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
---|
2204 | return (parsed.protocol === originURL.protocol &&
|
---|
2205 | parsed.host === originURL.host);
|
---|
2206 | };
|
---|
2207 | })() :
|
---|
2208 |
|
---|
2209 | // Non standard browser envs (web workers, react-native) lack needed support.
|
---|
2210 | (function nonStandardBrowserEnv() {
|
---|
2211 | return function isURLSameOrigin() {
|
---|
2212 | return true;
|
---|
2213 | };
|
---|
2214 | })();
|
---|
2215 |
|
---|
2216 | const cookies = platform.hasStandardBrowserEnv ?
|
---|
2217 |
|
---|
2218 | // Standard browser envs support document.cookie
|
---|
2219 | {
|
---|
2220 | write(name, value, expires, path, domain, secure) {
|
---|
2221 | const cookie = [name + '=' + encodeURIComponent(value)];
|
---|
2222 |
|
---|
2223 | utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
---|
2224 |
|
---|
2225 | utils$1.isString(path) && cookie.push('path=' + path);
|
---|
2226 |
|
---|
2227 | utils$1.isString(domain) && cookie.push('domain=' + domain);
|
---|
2228 |
|
---|
2229 | secure === true && cookie.push('secure');
|
---|
2230 |
|
---|
2231 | document.cookie = cookie.join('; ');
|
---|
2232 | },
|
---|
2233 |
|
---|
2234 | read(name) {
|
---|
2235 | const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
---|
2236 | return (match ? decodeURIComponent(match[3]) : null);
|
---|
2237 | },
|
---|
2238 |
|
---|
2239 | remove(name) {
|
---|
2240 | this.write(name, '', Date.now() - 86400000);
|
---|
2241 | }
|
---|
2242 | }
|
---|
2243 |
|
---|
2244 | :
|
---|
2245 |
|
---|
2246 | // Non-standard browser env (web workers, react-native) lack needed support.
|
---|
2247 | {
|
---|
2248 | write() {},
|
---|
2249 | read() {
|
---|
2250 | return null;
|
---|
2251 | },
|
---|
2252 | remove() {}
|
---|
2253 | };
|
---|
2254 |
|
---|
2255 | /**
|
---|
2256 | * Determines whether the specified URL is absolute
|
---|
2257 | *
|
---|
2258 | * @param {string} url The URL to test
|
---|
2259 | *
|
---|
2260 | * @returns {boolean} True if the specified URL is absolute, otherwise false
|
---|
2261 | */
|
---|
2262 | function isAbsoluteURL(url) {
|
---|
2263 | // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
---|
2264 | // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
---|
2265 | // by any combination of letters, digits, plus, period, or hyphen.
|
---|
2266 | return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
---|
2267 | }
|
---|
2268 |
|
---|
2269 | /**
|
---|
2270 | * Creates a new URL by combining the specified URLs
|
---|
2271 | *
|
---|
2272 | * @param {string} baseURL The base URL
|
---|
2273 | * @param {string} relativeURL The relative URL
|
---|
2274 | *
|
---|
2275 | * @returns {string} The combined URL
|
---|
2276 | */
|
---|
2277 | function combineURLs(baseURL, relativeURL) {
|
---|
2278 | return relativeURL
|
---|
2279 | ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
---|
2280 | : baseURL;
|
---|
2281 | }
|
---|
2282 |
|
---|
2283 | /**
|
---|
2284 | * Creates a new URL by combining the baseURL with the requestedURL,
|
---|
2285 | * only when the requestedURL is not already an absolute URL.
|
---|
2286 | * If the requestURL is absolute, this function returns the requestedURL untouched.
|
---|
2287 | *
|
---|
2288 | * @param {string} baseURL The base URL
|
---|
2289 | * @param {string} requestedURL Absolute or relative URL to combine
|
---|
2290 | *
|
---|
2291 | * @returns {string} The combined full path
|
---|
2292 | */
|
---|
2293 | function buildFullPath(baseURL, requestedURL) {
|
---|
2294 | if (baseURL && !isAbsoluteURL(requestedURL)) {
|
---|
2295 | return combineURLs(baseURL, requestedURL);
|
---|
2296 | }
|
---|
2297 | return requestedURL;
|
---|
2298 | }
|
---|
2299 |
|
---|
2300 | const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? { ...thing } : thing;
|
---|
2301 |
|
---|
2302 | /**
|
---|
2303 | * Config-specific merge-function which creates a new config-object
|
---|
2304 | * by merging two configuration objects together.
|
---|
2305 | *
|
---|
2306 | * @param {Object} config1
|
---|
2307 | * @param {Object} config2
|
---|
2308 | *
|
---|
2309 | * @returns {Object} New object resulting from merging config2 to config1
|
---|
2310 | */
|
---|
2311 | function mergeConfig$1(config1, config2) {
|
---|
2312 | // eslint-disable-next-line no-param-reassign
|
---|
2313 | config2 = config2 || {};
|
---|
2314 | const config = {};
|
---|
2315 |
|
---|
2316 | function getMergedValue(target, source, caseless) {
|
---|
2317 | if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
---|
2318 | return utils$1.merge.call({caseless}, target, source);
|
---|
2319 | } else if (utils$1.isPlainObject(source)) {
|
---|
2320 | return utils$1.merge({}, source);
|
---|
2321 | } else if (utils$1.isArray(source)) {
|
---|
2322 | return source.slice();
|
---|
2323 | }
|
---|
2324 | return source;
|
---|
2325 | }
|
---|
2326 |
|
---|
2327 | // eslint-disable-next-line consistent-return
|
---|
2328 | function mergeDeepProperties(a, b, caseless) {
|
---|
2329 | if (!utils$1.isUndefined(b)) {
|
---|
2330 | return getMergedValue(a, b, caseless);
|
---|
2331 | } else if (!utils$1.isUndefined(a)) {
|
---|
2332 | return getMergedValue(undefined, a, caseless);
|
---|
2333 | }
|
---|
2334 | }
|
---|
2335 |
|
---|
2336 | // eslint-disable-next-line consistent-return
|
---|
2337 | function valueFromConfig2(a, b) {
|
---|
2338 | if (!utils$1.isUndefined(b)) {
|
---|
2339 | return getMergedValue(undefined, b);
|
---|
2340 | }
|
---|
2341 | }
|
---|
2342 |
|
---|
2343 | // eslint-disable-next-line consistent-return
|
---|
2344 | function defaultToConfig2(a, b) {
|
---|
2345 | if (!utils$1.isUndefined(b)) {
|
---|
2346 | return getMergedValue(undefined, b);
|
---|
2347 | } else if (!utils$1.isUndefined(a)) {
|
---|
2348 | return getMergedValue(undefined, a);
|
---|
2349 | }
|
---|
2350 | }
|
---|
2351 |
|
---|
2352 | // eslint-disable-next-line consistent-return
|
---|
2353 | function mergeDirectKeys(a, b, prop) {
|
---|
2354 | if (prop in config2) {
|
---|
2355 | return getMergedValue(a, b);
|
---|
2356 | } else if (prop in config1) {
|
---|
2357 | return getMergedValue(undefined, a);
|
---|
2358 | }
|
---|
2359 | }
|
---|
2360 |
|
---|
2361 | const mergeMap = {
|
---|
2362 | url: valueFromConfig2,
|
---|
2363 | method: valueFromConfig2,
|
---|
2364 | data: valueFromConfig2,
|
---|
2365 | baseURL: defaultToConfig2,
|
---|
2366 | transformRequest: defaultToConfig2,
|
---|
2367 | transformResponse: defaultToConfig2,
|
---|
2368 | paramsSerializer: defaultToConfig2,
|
---|
2369 | timeout: defaultToConfig2,
|
---|
2370 | timeoutMessage: defaultToConfig2,
|
---|
2371 | withCredentials: defaultToConfig2,
|
---|
2372 | withXSRFToken: defaultToConfig2,
|
---|
2373 | adapter: defaultToConfig2,
|
---|
2374 | responseType: defaultToConfig2,
|
---|
2375 | xsrfCookieName: defaultToConfig2,
|
---|
2376 | xsrfHeaderName: defaultToConfig2,
|
---|
2377 | onUploadProgress: defaultToConfig2,
|
---|
2378 | onDownloadProgress: defaultToConfig2,
|
---|
2379 | decompress: defaultToConfig2,
|
---|
2380 | maxContentLength: defaultToConfig2,
|
---|
2381 | maxBodyLength: defaultToConfig2,
|
---|
2382 | beforeRedirect: defaultToConfig2,
|
---|
2383 | transport: defaultToConfig2,
|
---|
2384 | httpAgent: defaultToConfig2,
|
---|
2385 | httpsAgent: defaultToConfig2,
|
---|
2386 | cancelToken: defaultToConfig2,
|
---|
2387 | socketPath: defaultToConfig2,
|
---|
2388 | responseEncoding: defaultToConfig2,
|
---|
2389 | validateStatus: mergeDirectKeys,
|
---|
2390 | headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
---|
2391 | };
|
---|
2392 |
|
---|
2393 | utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
---|
2394 | const merge = mergeMap[prop] || mergeDeepProperties;
|
---|
2395 | const configValue = merge(config1[prop], config2[prop], prop);
|
---|
2396 | (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
---|
2397 | });
|
---|
2398 |
|
---|
2399 | return config;
|
---|
2400 | }
|
---|
2401 |
|
---|
2402 | const resolveConfig = (config) => {
|
---|
2403 | const newConfig = mergeConfig$1({}, config);
|
---|
2404 |
|
---|
2405 | let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
---|
2406 |
|
---|
2407 | newConfig.headers = headers = AxiosHeaders$2.from(headers);
|
---|
2408 |
|
---|
2409 | newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
|
---|
2410 |
|
---|
2411 | // HTTP basic authentication
|
---|
2412 | if (auth) {
|
---|
2413 | headers.set('Authorization', 'Basic ' +
|
---|
2414 | btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
|
---|
2415 | );
|
---|
2416 | }
|
---|
2417 |
|
---|
2418 | let contentType;
|
---|
2419 |
|
---|
2420 | if (utils$1.isFormData(data)) {
|
---|
2421 | if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
---|
2422 | headers.setContentType(undefined); // Let the browser set it
|
---|
2423 | } else if ((contentType = headers.getContentType()) !== false) {
|
---|
2424 | // fix semicolon duplication issue for ReactNative FormData implementation
|
---|
2425 | const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
---|
2426 | headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
---|
2427 | }
|
---|
2428 | }
|
---|
2429 |
|
---|
2430 | // Add xsrf header
|
---|
2431 | // This is only done if running in a standard browser environment.
|
---|
2432 | // Specifically not if we're in a web worker, or react-native.
|
---|
2433 |
|
---|
2434 | if (platform.hasStandardBrowserEnv) {
|
---|
2435 | withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
---|
2436 |
|
---|
2437 | if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
|
---|
2438 | // Add xsrf header
|
---|
2439 | const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
---|
2440 |
|
---|
2441 | if (xsrfValue) {
|
---|
2442 | headers.set(xsrfHeaderName, xsrfValue);
|
---|
2443 | }
|
---|
2444 | }
|
---|
2445 | }
|
---|
2446 |
|
---|
2447 | return newConfig;
|
---|
2448 | };
|
---|
2449 |
|
---|
2450 | const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
---|
2451 |
|
---|
2452 | const xhrAdapter = isXHRAdapterSupported && function (config) {
|
---|
2453 | return new Promise(function dispatchXhrRequest(resolve, reject) {
|
---|
2454 | const _config = resolveConfig(config);
|
---|
2455 | let requestData = _config.data;
|
---|
2456 | const requestHeaders = AxiosHeaders$2.from(_config.headers).normalize();
|
---|
2457 | let {responseType, onUploadProgress, onDownloadProgress} = _config;
|
---|
2458 | let onCanceled;
|
---|
2459 | let uploadThrottled, downloadThrottled;
|
---|
2460 | let flushUpload, flushDownload;
|
---|
2461 |
|
---|
2462 | function done() {
|
---|
2463 | flushUpload && flushUpload(); // flush events
|
---|
2464 | flushDownload && flushDownload(); // flush events
|
---|
2465 |
|
---|
2466 | _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
---|
2467 |
|
---|
2468 | _config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
---|
2469 | }
|
---|
2470 |
|
---|
2471 | let request = new XMLHttpRequest();
|
---|
2472 |
|
---|
2473 | request.open(_config.method.toUpperCase(), _config.url, true);
|
---|
2474 |
|
---|
2475 | // Set the request timeout in MS
|
---|
2476 | request.timeout = _config.timeout;
|
---|
2477 |
|
---|
2478 | function onloadend() {
|
---|
2479 | if (!request) {
|
---|
2480 | return;
|
---|
2481 | }
|
---|
2482 | // Prepare the response
|
---|
2483 | const responseHeaders = AxiosHeaders$2.from(
|
---|
2484 | 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
---|
2485 | );
|
---|
2486 | const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
---|
2487 | request.responseText : request.response;
|
---|
2488 | const response = {
|
---|
2489 | data: responseData,
|
---|
2490 | status: request.status,
|
---|
2491 | statusText: request.statusText,
|
---|
2492 | headers: responseHeaders,
|
---|
2493 | config,
|
---|
2494 | request
|
---|
2495 | };
|
---|
2496 |
|
---|
2497 | settle(function _resolve(value) {
|
---|
2498 | resolve(value);
|
---|
2499 | done();
|
---|
2500 | }, function _reject(err) {
|
---|
2501 | reject(err);
|
---|
2502 | done();
|
---|
2503 | }, response);
|
---|
2504 |
|
---|
2505 | // Clean up request
|
---|
2506 | request = null;
|
---|
2507 | }
|
---|
2508 |
|
---|
2509 | if ('onloadend' in request) {
|
---|
2510 | // Use onloadend if available
|
---|
2511 | request.onloadend = onloadend;
|
---|
2512 | } else {
|
---|
2513 | // Listen for ready state to emulate onloadend
|
---|
2514 | request.onreadystatechange = function handleLoad() {
|
---|
2515 | if (!request || request.readyState !== 4) {
|
---|
2516 | return;
|
---|
2517 | }
|
---|
2518 |
|
---|
2519 | // The request errored out and we didn't get a response, this will be
|
---|
2520 | // handled by onerror instead
|
---|
2521 | // With one exception: request that using file: protocol, most browsers
|
---|
2522 | // will return status as 0 even though it's a successful request
|
---|
2523 | if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
---|
2524 | return;
|
---|
2525 | }
|
---|
2526 | // readystate handler is calling before onerror or ontimeout handlers,
|
---|
2527 | // so we should call onloadend on the next 'tick'
|
---|
2528 | setTimeout(onloadend);
|
---|
2529 | };
|
---|
2530 | }
|
---|
2531 |
|
---|
2532 | // Handle browser request cancellation (as opposed to a manual cancellation)
|
---|
2533 | request.onabort = function handleAbort() {
|
---|
2534 | if (!request) {
|
---|
2535 | return;
|
---|
2536 | }
|
---|
2537 |
|
---|
2538 | reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
---|
2539 |
|
---|
2540 | // Clean up request
|
---|
2541 | request = null;
|
---|
2542 | };
|
---|
2543 |
|
---|
2544 | // Handle low level network errors
|
---|
2545 | request.onerror = function handleError() {
|
---|
2546 | // Real errors are hidden from us by the browser
|
---|
2547 | // onerror should only fire if it's a network error
|
---|
2548 | reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
|
---|
2549 |
|
---|
2550 | // Clean up request
|
---|
2551 | request = null;
|
---|
2552 | };
|
---|
2553 |
|
---|
2554 | // Handle timeout
|
---|
2555 | request.ontimeout = function handleTimeout() {
|
---|
2556 | let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
---|
2557 | const transitional = _config.transitional || transitionalDefaults;
|
---|
2558 | if (_config.timeoutErrorMessage) {
|
---|
2559 | timeoutErrorMessage = _config.timeoutErrorMessage;
|
---|
2560 | }
|
---|
2561 | reject(new AxiosError$1(
|
---|
2562 | timeoutErrorMessage,
|
---|
2563 | transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
---|
2564 | config,
|
---|
2565 | request));
|
---|
2566 |
|
---|
2567 | // Clean up request
|
---|
2568 | request = null;
|
---|
2569 | };
|
---|
2570 |
|
---|
2571 | // Remove Content-Type if data is undefined
|
---|
2572 | requestData === undefined && requestHeaders.setContentType(null);
|
---|
2573 |
|
---|
2574 | // Add headers to the request
|
---|
2575 | if ('setRequestHeader' in request) {
|
---|
2576 | utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
---|
2577 | request.setRequestHeader(key, val);
|
---|
2578 | });
|
---|
2579 | }
|
---|
2580 |
|
---|
2581 | // Add withCredentials to request if needed
|
---|
2582 | if (!utils$1.isUndefined(_config.withCredentials)) {
|
---|
2583 | request.withCredentials = !!_config.withCredentials;
|
---|
2584 | }
|
---|
2585 |
|
---|
2586 | // Add responseType to request if needed
|
---|
2587 | if (responseType && responseType !== 'json') {
|
---|
2588 | request.responseType = _config.responseType;
|
---|
2589 | }
|
---|
2590 |
|
---|
2591 | // Handle progress if needed
|
---|
2592 | if (onDownloadProgress) {
|
---|
2593 | ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
|
---|
2594 | request.addEventListener('progress', downloadThrottled);
|
---|
2595 | }
|
---|
2596 |
|
---|
2597 | // Not all browsers support upload events
|
---|
2598 | if (onUploadProgress && request.upload) {
|
---|
2599 | ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
---|
2600 |
|
---|
2601 | request.upload.addEventListener('progress', uploadThrottled);
|
---|
2602 |
|
---|
2603 | request.upload.addEventListener('loadend', flushUpload);
|
---|
2604 | }
|
---|
2605 |
|
---|
2606 | if (_config.cancelToken || _config.signal) {
|
---|
2607 | // Handle cancellation
|
---|
2608 | // eslint-disable-next-line func-names
|
---|
2609 | onCanceled = cancel => {
|
---|
2610 | if (!request) {
|
---|
2611 | return;
|
---|
2612 | }
|
---|
2613 | reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
---|
2614 | request.abort();
|
---|
2615 | request = null;
|
---|
2616 | };
|
---|
2617 |
|
---|
2618 | _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
---|
2619 | if (_config.signal) {
|
---|
2620 | _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
---|
2621 | }
|
---|
2622 | }
|
---|
2623 |
|
---|
2624 | const protocol = parseProtocol(_config.url);
|
---|
2625 |
|
---|
2626 | if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
---|
2627 | reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
---|
2628 | return;
|
---|
2629 | }
|
---|
2630 |
|
---|
2631 |
|
---|
2632 | // Send the request
|
---|
2633 | request.send(requestData || null);
|
---|
2634 | });
|
---|
2635 | };
|
---|
2636 |
|
---|
2637 | const composeSignals = (signals, timeout) => {
|
---|
2638 | const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
---|
2639 |
|
---|
2640 | if (timeout || length) {
|
---|
2641 | let controller = new AbortController();
|
---|
2642 |
|
---|
2643 | let aborted;
|
---|
2644 |
|
---|
2645 | const onabort = function (reason) {
|
---|
2646 | if (!aborted) {
|
---|
2647 | aborted = true;
|
---|
2648 | unsubscribe();
|
---|
2649 | const err = reason instanceof Error ? reason : this.reason;
|
---|
2650 | controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
|
---|
2651 | }
|
---|
2652 | };
|
---|
2653 |
|
---|
2654 | let timer = timeout && setTimeout(() => {
|
---|
2655 | timer = null;
|
---|
2656 | onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
|
---|
2657 | }, timeout);
|
---|
2658 |
|
---|
2659 | const unsubscribe = () => {
|
---|
2660 | if (signals) {
|
---|
2661 | timer && clearTimeout(timer);
|
---|
2662 | timer = null;
|
---|
2663 | signals.forEach(signal => {
|
---|
2664 | signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
---|
2665 | });
|
---|
2666 | signals = null;
|
---|
2667 | }
|
---|
2668 | };
|
---|
2669 |
|
---|
2670 | signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
---|
2671 |
|
---|
2672 | const {signal} = controller;
|
---|
2673 |
|
---|
2674 | signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
---|
2675 |
|
---|
2676 | return signal;
|
---|
2677 | }
|
---|
2678 | };
|
---|
2679 |
|
---|
2680 | const composeSignals$1 = composeSignals;
|
---|
2681 |
|
---|
2682 | const streamChunk = function* (chunk, chunkSize) {
|
---|
2683 | let len = chunk.byteLength;
|
---|
2684 |
|
---|
2685 | if (!chunkSize || len < chunkSize) {
|
---|
2686 | yield chunk;
|
---|
2687 | return;
|
---|
2688 | }
|
---|
2689 |
|
---|
2690 | let pos = 0;
|
---|
2691 | let end;
|
---|
2692 |
|
---|
2693 | while (pos < len) {
|
---|
2694 | end = pos + chunkSize;
|
---|
2695 | yield chunk.slice(pos, end);
|
---|
2696 | pos = end;
|
---|
2697 | }
|
---|
2698 | };
|
---|
2699 |
|
---|
2700 | const readBytes = async function* (iterable, chunkSize) {
|
---|
2701 | for await (const chunk of readStream(iterable)) {
|
---|
2702 | yield* streamChunk(chunk, chunkSize);
|
---|
2703 | }
|
---|
2704 | };
|
---|
2705 |
|
---|
2706 | const readStream = async function* (stream) {
|
---|
2707 | if (stream[Symbol.asyncIterator]) {
|
---|
2708 | yield* stream;
|
---|
2709 | return;
|
---|
2710 | }
|
---|
2711 |
|
---|
2712 | const reader = stream.getReader();
|
---|
2713 | try {
|
---|
2714 | for (;;) {
|
---|
2715 | const {done, value} = await reader.read();
|
---|
2716 | if (done) {
|
---|
2717 | break;
|
---|
2718 | }
|
---|
2719 | yield value;
|
---|
2720 | }
|
---|
2721 | } finally {
|
---|
2722 | await reader.cancel();
|
---|
2723 | }
|
---|
2724 | };
|
---|
2725 |
|
---|
2726 | const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
---|
2727 | const iterator = readBytes(stream, chunkSize);
|
---|
2728 |
|
---|
2729 | let bytes = 0;
|
---|
2730 | let done;
|
---|
2731 | let _onFinish = (e) => {
|
---|
2732 | if (!done) {
|
---|
2733 | done = true;
|
---|
2734 | onFinish && onFinish(e);
|
---|
2735 | }
|
---|
2736 | };
|
---|
2737 |
|
---|
2738 | return new ReadableStream({
|
---|
2739 | async pull(controller) {
|
---|
2740 | try {
|
---|
2741 | const {done, value} = await iterator.next();
|
---|
2742 |
|
---|
2743 | if (done) {
|
---|
2744 | _onFinish();
|
---|
2745 | controller.close();
|
---|
2746 | return;
|
---|
2747 | }
|
---|
2748 |
|
---|
2749 | let len = value.byteLength;
|
---|
2750 | if (onProgress) {
|
---|
2751 | let loadedBytes = bytes += len;
|
---|
2752 | onProgress(loadedBytes);
|
---|
2753 | }
|
---|
2754 | controller.enqueue(new Uint8Array(value));
|
---|
2755 | } catch (err) {
|
---|
2756 | _onFinish(err);
|
---|
2757 | throw err;
|
---|
2758 | }
|
---|
2759 | },
|
---|
2760 | cancel(reason) {
|
---|
2761 | _onFinish(reason);
|
---|
2762 | return iterator.return();
|
---|
2763 | }
|
---|
2764 | }, {
|
---|
2765 | highWaterMark: 2
|
---|
2766 | })
|
---|
2767 | };
|
---|
2768 |
|
---|
2769 | const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
|
---|
2770 | const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
|
---|
2771 |
|
---|
2772 | // used only inside the fetch adapter
|
---|
2773 | const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
---|
2774 | ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
---|
2775 | async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
---|
2776 | );
|
---|
2777 |
|
---|
2778 | const test = (fn, ...args) => {
|
---|
2779 | try {
|
---|
2780 | return !!fn(...args);
|
---|
2781 | } catch (e) {
|
---|
2782 | return false
|
---|
2783 | }
|
---|
2784 | };
|
---|
2785 |
|
---|
2786 | const supportsRequestStream = isReadableStreamSupported && test(() => {
|
---|
2787 | let duplexAccessed = false;
|
---|
2788 |
|
---|
2789 | const hasContentType = new Request(platform.origin, {
|
---|
2790 | body: new ReadableStream(),
|
---|
2791 | method: 'POST',
|
---|
2792 | get duplex() {
|
---|
2793 | duplexAccessed = true;
|
---|
2794 | return 'half';
|
---|
2795 | },
|
---|
2796 | }).headers.has('Content-Type');
|
---|
2797 |
|
---|
2798 | return duplexAccessed && !hasContentType;
|
---|
2799 | });
|
---|
2800 |
|
---|
2801 | const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
---|
2802 |
|
---|
2803 | const supportsResponseStream = isReadableStreamSupported &&
|
---|
2804 | test(() => utils$1.isReadableStream(new Response('').body));
|
---|
2805 |
|
---|
2806 |
|
---|
2807 | const resolvers = {
|
---|
2808 | stream: supportsResponseStream && ((res) => res.body)
|
---|
2809 | };
|
---|
2810 |
|
---|
2811 | isFetchSupported && (((res) => {
|
---|
2812 | ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
---|
2813 | !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
---|
2814 | (_, config) => {
|
---|
2815 | throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
|
---|
2816 | });
|
---|
2817 | });
|
---|
2818 | })(new Response));
|
---|
2819 |
|
---|
2820 | const getBodyLength = async (body) => {
|
---|
2821 | if (body == null) {
|
---|
2822 | return 0;
|
---|
2823 | }
|
---|
2824 |
|
---|
2825 | if(utils$1.isBlob(body)) {
|
---|
2826 | return body.size;
|
---|
2827 | }
|
---|
2828 |
|
---|
2829 | if(utils$1.isSpecCompliantForm(body)) {
|
---|
2830 | const _request = new Request(platform.origin, {
|
---|
2831 | method: 'POST',
|
---|
2832 | body,
|
---|
2833 | });
|
---|
2834 | return (await _request.arrayBuffer()).byteLength;
|
---|
2835 | }
|
---|
2836 |
|
---|
2837 | if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
---|
2838 | return body.byteLength;
|
---|
2839 | }
|
---|
2840 |
|
---|
2841 | if(utils$1.isURLSearchParams(body)) {
|
---|
2842 | body = body + '';
|
---|
2843 | }
|
---|
2844 |
|
---|
2845 | if(utils$1.isString(body)) {
|
---|
2846 | return (await encodeText(body)).byteLength;
|
---|
2847 | }
|
---|
2848 | };
|
---|
2849 |
|
---|
2850 | const resolveBodyLength = async (headers, body) => {
|
---|
2851 | const length = utils$1.toFiniteNumber(headers.getContentLength());
|
---|
2852 |
|
---|
2853 | return length == null ? getBodyLength(body) : length;
|
---|
2854 | };
|
---|
2855 |
|
---|
2856 | const fetchAdapter = isFetchSupported && (async (config) => {
|
---|
2857 | let {
|
---|
2858 | url,
|
---|
2859 | method,
|
---|
2860 | data,
|
---|
2861 | signal,
|
---|
2862 | cancelToken,
|
---|
2863 | timeout,
|
---|
2864 | onDownloadProgress,
|
---|
2865 | onUploadProgress,
|
---|
2866 | responseType,
|
---|
2867 | headers,
|
---|
2868 | withCredentials = 'same-origin',
|
---|
2869 | fetchOptions
|
---|
2870 | } = resolveConfig(config);
|
---|
2871 |
|
---|
2872 | responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
---|
2873 |
|
---|
2874 | let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
---|
2875 |
|
---|
2876 | let request;
|
---|
2877 |
|
---|
2878 | const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
---|
2879 | composedSignal.unsubscribe();
|
---|
2880 | });
|
---|
2881 |
|
---|
2882 | let requestContentLength;
|
---|
2883 |
|
---|
2884 | try {
|
---|
2885 | if (
|
---|
2886 | onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
---|
2887 | (requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
---|
2888 | ) {
|
---|
2889 | let _request = new Request(url, {
|
---|
2890 | method: 'POST',
|
---|
2891 | body: data,
|
---|
2892 | duplex: "half"
|
---|
2893 | });
|
---|
2894 |
|
---|
2895 | let contentTypeHeader;
|
---|
2896 |
|
---|
2897 | if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
---|
2898 | headers.setContentType(contentTypeHeader);
|
---|
2899 | }
|
---|
2900 |
|
---|
2901 | if (_request.body) {
|
---|
2902 | const [onProgress, flush] = progressEventDecorator(
|
---|
2903 | requestContentLength,
|
---|
2904 | progressEventReducer(asyncDecorator(onUploadProgress))
|
---|
2905 | );
|
---|
2906 |
|
---|
2907 | data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
---|
2908 | }
|
---|
2909 | }
|
---|
2910 |
|
---|
2911 | if (!utils$1.isString(withCredentials)) {
|
---|
2912 | withCredentials = withCredentials ? 'include' : 'omit';
|
---|
2913 | }
|
---|
2914 |
|
---|
2915 | // Cloudflare Workers throws when credentials are defined
|
---|
2916 | // see https://github.com/cloudflare/workerd/issues/902
|
---|
2917 | const isCredentialsSupported = "credentials" in Request.prototype;
|
---|
2918 | request = new Request(url, {
|
---|
2919 | ...fetchOptions,
|
---|
2920 | signal: composedSignal,
|
---|
2921 | method: method.toUpperCase(),
|
---|
2922 | headers: headers.normalize().toJSON(),
|
---|
2923 | body: data,
|
---|
2924 | duplex: "half",
|
---|
2925 | credentials: isCredentialsSupported ? withCredentials : undefined
|
---|
2926 | });
|
---|
2927 |
|
---|
2928 | let response = await fetch(request);
|
---|
2929 |
|
---|
2930 | const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
---|
2931 |
|
---|
2932 | if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
---|
2933 | const options = {};
|
---|
2934 |
|
---|
2935 | ['status', 'statusText', 'headers'].forEach(prop => {
|
---|
2936 | options[prop] = response[prop];
|
---|
2937 | });
|
---|
2938 |
|
---|
2939 | const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
---|
2940 |
|
---|
2941 | const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
---|
2942 | responseContentLength,
|
---|
2943 | progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
---|
2944 | ) || [];
|
---|
2945 |
|
---|
2946 | response = new Response(
|
---|
2947 | trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
---|
2948 | flush && flush();
|
---|
2949 | unsubscribe && unsubscribe();
|
---|
2950 | }),
|
---|
2951 | options
|
---|
2952 | );
|
---|
2953 | }
|
---|
2954 |
|
---|
2955 | responseType = responseType || 'text';
|
---|
2956 |
|
---|
2957 | let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
---|
2958 |
|
---|
2959 | !isStreamResponse && unsubscribe && unsubscribe();
|
---|
2960 |
|
---|
2961 | return await new Promise((resolve, reject) => {
|
---|
2962 | settle(resolve, reject, {
|
---|
2963 | data: responseData,
|
---|
2964 | headers: AxiosHeaders$2.from(response.headers),
|
---|
2965 | status: response.status,
|
---|
2966 | statusText: response.statusText,
|
---|
2967 | config,
|
---|
2968 | request
|
---|
2969 | });
|
---|
2970 | })
|
---|
2971 | } catch (err) {
|
---|
2972 | unsubscribe && unsubscribe();
|
---|
2973 |
|
---|
2974 | if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
---|
2975 | throw Object.assign(
|
---|
2976 | new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
|
---|
2977 | {
|
---|
2978 | cause: err.cause || err
|
---|
2979 | }
|
---|
2980 | )
|
---|
2981 | }
|
---|
2982 |
|
---|
2983 | throw AxiosError$1.from(err, err && err.code, config, request);
|
---|
2984 | }
|
---|
2985 | });
|
---|
2986 |
|
---|
2987 | const knownAdapters = {
|
---|
2988 | http: httpAdapter,
|
---|
2989 | xhr: xhrAdapter,
|
---|
2990 | fetch: fetchAdapter
|
---|
2991 | };
|
---|
2992 |
|
---|
2993 | utils$1.forEach(knownAdapters, (fn, value) => {
|
---|
2994 | if (fn) {
|
---|
2995 | try {
|
---|
2996 | Object.defineProperty(fn, 'name', {value});
|
---|
2997 | } catch (e) {
|
---|
2998 | // eslint-disable-next-line no-empty
|
---|
2999 | }
|
---|
3000 | Object.defineProperty(fn, 'adapterName', {value});
|
---|
3001 | }
|
---|
3002 | });
|
---|
3003 |
|
---|
3004 | const renderReason = (reason) => `- ${reason}`;
|
---|
3005 |
|
---|
3006 | const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
---|
3007 |
|
---|
3008 | const adapters = {
|
---|
3009 | getAdapter: (adapters) => {
|
---|
3010 | adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
---|
3011 |
|
---|
3012 | const {length} = adapters;
|
---|
3013 | let nameOrAdapter;
|
---|
3014 | let adapter;
|
---|
3015 |
|
---|
3016 | const rejectedReasons = {};
|
---|
3017 |
|
---|
3018 | for (let i = 0; i < length; i++) {
|
---|
3019 | nameOrAdapter = adapters[i];
|
---|
3020 | let id;
|
---|
3021 |
|
---|
3022 | adapter = nameOrAdapter;
|
---|
3023 |
|
---|
3024 | if (!isResolvedHandle(nameOrAdapter)) {
|
---|
3025 | adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
---|
3026 |
|
---|
3027 | if (adapter === undefined) {
|
---|
3028 | throw new AxiosError$1(`Unknown adapter '${id}'`);
|
---|
3029 | }
|
---|
3030 | }
|
---|
3031 |
|
---|
3032 | if (adapter) {
|
---|
3033 | break;
|
---|
3034 | }
|
---|
3035 |
|
---|
3036 | rejectedReasons[id || '#' + i] = adapter;
|
---|
3037 | }
|
---|
3038 |
|
---|
3039 | if (!adapter) {
|
---|
3040 |
|
---|
3041 | const reasons = Object.entries(rejectedReasons)
|
---|
3042 | .map(([id, state]) => `adapter ${id} ` +
|
---|
3043 | (state === false ? 'is not supported by the environment' : 'is not available in the build')
|
---|
3044 | );
|
---|
3045 |
|
---|
3046 | let s = length ?
|
---|
3047 | (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
---|
3048 | 'as no adapter specified';
|
---|
3049 |
|
---|
3050 | throw new AxiosError$1(
|
---|
3051 | `There is no suitable adapter to dispatch the request ` + s,
|
---|
3052 | 'ERR_NOT_SUPPORT'
|
---|
3053 | );
|
---|
3054 | }
|
---|
3055 |
|
---|
3056 | return adapter;
|
---|
3057 | },
|
---|
3058 | adapters: knownAdapters
|
---|
3059 | };
|
---|
3060 |
|
---|
3061 | /**
|
---|
3062 | * Throws a `CanceledError` if cancellation has been requested.
|
---|
3063 | *
|
---|
3064 | * @param {Object} config The config that is to be used for the request
|
---|
3065 | *
|
---|
3066 | * @returns {void}
|
---|
3067 | */
|
---|
3068 | function throwIfCancellationRequested(config) {
|
---|
3069 | if (config.cancelToken) {
|
---|
3070 | config.cancelToken.throwIfRequested();
|
---|
3071 | }
|
---|
3072 |
|
---|
3073 | if (config.signal && config.signal.aborted) {
|
---|
3074 | throw new CanceledError$1(null, config);
|
---|
3075 | }
|
---|
3076 | }
|
---|
3077 |
|
---|
3078 | /**
|
---|
3079 | * Dispatch a request to the server using the configured adapter.
|
---|
3080 | *
|
---|
3081 | * @param {object} config The config that is to be used for the request
|
---|
3082 | *
|
---|
3083 | * @returns {Promise} The Promise to be fulfilled
|
---|
3084 | */
|
---|
3085 | function dispatchRequest(config) {
|
---|
3086 | throwIfCancellationRequested(config);
|
---|
3087 |
|
---|
3088 | config.headers = AxiosHeaders$2.from(config.headers);
|
---|
3089 |
|
---|
3090 | // Transform request data
|
---|
3091 | config.data = transformData.call(
|
---|
3092 | config,
|
---|
3093 | config.transformRequest
|
---|
3094 | );
|
---|
3095 |
|
---|
3096 | if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
---|
3097 | config.headers.setContentType('application/x-www-form-urlencoded', false);
|
---|
3098 | }
|
---|
3099 |
|
---|
3100 | const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
---|
3101 |
|
---|
3102 | return adapter(config).then(function onAdapterResolution(response) {
|
---|
3103 | throwIfCancellationRequested(config);
|
---|
3104 |
|
---|
3105 | // Transform response data
|
---|
3106 | response.data = transformData.call(
|
---|
3107 | config,
|
---|
3108 | config.transformResponse,
|
---|
3109 | response
|
---|
3110 | );
|
---|
3111 |
|
---|
3112 | response.headers = AxiosHeaders$2.from(response.headers);
|
---|
3113 |
|
---|
3114 | return response;
|
---|
3115 | }, function onAdapterRejection(reason) {
|
---|
3116 | if (!isCancel$1(reason)) {
|
---|
3117 | throwIfCancellationRequested(config);
|
---|
3118 |
|
---|
3119 | // Transform response data
|
---|
3120 | if (reason && reason.response) {
|
---|
3121 | reason.response.data = transformData.call(
|
---|
3122 | config,
|
---|
3123 | config.transformResponse,
|
---|
3124 | reason.response
|
---|
3125 | );
|
---|
3126 | reason.response.headers = AxiosHeaders$2.from(reason.response.headers);
|
---|
3127 | }
|
---|
3128 | }
|
---|
3129 |
|
---|
3130 | return Promise.reject(reason);
|
---|
3131 | });
|
---|
3132 | }
|
---|
3133 |
|
---|
3134 | const VERSION$1 = "1.7.7";
|
---|
3135 |
|
---|
3136 | const validators$1 = {};
|
---|
3137 |
|
---|
3138 | // eslint-disable-next-line func-names
|
---|
3139 | ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
|
---|
3140 | validators$1[type] = function validator(thing) {
|
---|
3141 | return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
---|
3142 | };
|
---|
3143 | });
|
---|
3144 |
|
---|
3145 | const deprecatedWarnings = {};
|
---|
3146 |
|
---|
3147 | /**
|
---|
3148 | * Transitional option validator
|
---|
3149 | *
|
---|
3150 | * @param {function|boolean?} validator - set to false if the transitional option has been removed
|
---|
3151 | * @param {string?} version - deprecated version / removed since version
|
---|
3152 | * @param {string?} message - some message with additional info
|
---|
3153 | *
|
---|
3154 | * @returns {function}
|
---|
3155 | */
|
---|
3156 | validators$1.transitional = function transitional(validator, version, message) {
|
---|
3157 | function formatMessage(opt, desc) {
|
---|
3158 | return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
---|
3159 | }
|
---|
3160 |
|
---|
3161 | // eslint-disable-next-line func-names
|
---|
3162 | return (value, opt, opts) => {
|
---|
3163 | if (validator === false) {
|
---|
3164 | throw new AxiosError$1(
|
---|
3165 | formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
---|
3166 | AxiosError$1.ERR_DEPRECATED
|
---|
3167 | );
|
---|
3168 | }
|
---|
3169 |
|
---|
3170 | if (version && !deprecatedWarnings[opt]) {
|
---|
3171 | deprecatedWarnings[opt] = true;
|
---|
3172 | // eslint-disable-next-line no-console
|
---|
3173 | console.warn(
|
---|
3174 | formatMessage(
|
---|
3175 | opt,
|
---|
3176 | ' has been deprecated since v' + version + ' and will be removed in the near future'
|
---|
3177 | )
|
---|
3178 | );
|
---|
3179 | }
|
---|
3180 |
|
---|
3181 | return validator ? validator(value, opt, opts) : true;
|
---|
3182 | };
|
---|
3183 | };
|
---|
3184 |
|
---|
3185 | /**
|
---|
3186 | * Assert object's properties type
|
---|
3187 | *
|
---|
3188 | * @param {object} options
|
---|
3189 | * @param {object} schema
|
---|
3190 | * @param {boolean?} allowUnknown
|
---|
3191 | *
|
---|
3192 | * @returns {object}
|
---|
3193 | */
|
---|
3194 |
|
---|
3195 | function assertOptions(options, schema, allowUnknown) {
|
---|
3196 | if (typeof options !== 'object') {
|
---|
3197 | throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
|
---|
3198 | }
|
---|
3199 | const keys = Object.keys(options);
|
---|
3200 | let i = keys.length;
|
---|
3201 | while (i-- > 0) {
|
---|
3202 | const opt = keys[i];
|
---|
3203 | const validator = schema[opt];
|
---|
3204 | if (validator) {
|
---|
3205 | const value = options[opt];
|
---|
3206 | const result = value === undefined || validator(value, opt, options);
|
---|
3207 | if (result !== true) {
|
---|
3208 | throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
|
---|
3209 | }
|
---|
3210 | continue;
|
---|
3211 | }
|
---|
3212 | if (allowUnknown !== true) {
|
---|
3213 | throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
|
---|
3214 | }
|
---|
3215 | }
|
---|
3216 | }
|
---|
3217 |
|
---|
3218 | const validator = {
|
---|
3219 | assertOptions,
|
---|
3220 | validators: validators$1
|
---|
3221 | };
|
---|
3222 |
|
---|
3223 | const validators = validator.validators;
|
---|
3224 |
|
---|
3225 | /**
|
---|
3226 | * Create a new instance of Axios
|
---|
3227 | *
|
---|
3228 | * @param {Object} instanceConfig The default config for the instance
|
---|
3229 | *
|
---|
3230 | * @return {Axios} A new instance of Axios
|
---|
3231 | */
|
---|
3232 | class Axios$1 {
|
---|
3233 | constructor(instanceConfig) {
|
---|
3234 | this.defaults = instanceConfig;
|
---|
3235 | this.interceptors = {
|
---|
3236 | request: new InterceptorManager$1(),
|
---|
3237 | response: new InterceptorManager$1()
|
---|
3238 | };
|
---|
3239 | }
|
---|
3240 |
|
---|
3241 | /**
|
---|
3242 | * Dispatch a request
|
---|
3243 | *
|
---|
3244 | * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
---|
3245 | * @param {?Object} config
|
---|
3246 | *
|
---|
3247 | * @returns {Promise} The Promise to be fulfilled
|
---|
3248 | */
|
---|
3249 | async request(configOrUrl, config) {
|
---|
3250 | try {
|
---|
3251 | return await this._request(configOrUrl, config);
|
---|
3252 | } catch (err) {
|
---|
3253 | if (err instanceof Error) {
|
---|
3254 | let dummy;
|
---|
3255 |
|
---|
3256 | Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
|
---|
3257 |
|
---|
3258 | // slice off the Error: ... line
|
---|
3259 | const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
---|
3260 | try {
|
---|
3261 | if (!err.stack) {
|
---|
3262 | err.stack = stack;
|
---|
3263 | // match without the 2 top stack lines
|
---|
3264 | } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
|
---|
3265 | err.stack += '\n' + stack;
|
---|
3266 | }
|
---|
3267 | } catch (e) {
|
---|
3268 | // ignore the case where "stack" is an un-writable property
|
---|
3269 | }
|
---|
3270 | }
|
---|
3271 |
|
---|
3272 | throw err;
|
---|
3273 | }
|
---|
3274 | }
|
---|
3275 |
|
---|
3276 | _request(configOrUrl, config) {
|
---|
3277 | /*eslint no-param-reassign:0*/
|
---|
3278 | // Allow for axios('example/url'[, config]) a la fetch API
|
---|
3279 | if (typeof configOrUrl === 'string') {
|
---|
3280 | config = config || {};
|
---|
3281 | config.url = configOrUrl;
|
---|
3282 | } else {
|
---|
3283 | config = configOrUrl || {};
|
---|
3284 | }
|
---|
3285 |
|
---|
3286 | config = mergeConfig$1(this.defaults, config);
|
---|
3287 |
|
---|
3288 | const {transitional, paramsSerializer, headers} = config;
|
---|
3289 |
|
---|
3290 | if (transitional !== undefined) {
|
---|
3291 | validator.assertOptions(transitional, {
|
---|
3292 | silentJSONParsing: validators.transitional(validators.boolean),
|
---|
3293 | forcedJSONParsing: validators.transitional(validators.boolean),
|
---|
3294 | clarifyTimeoutError: validators.transitional(validators.boolean)
|
---|
3295 | }, false);
|
---|
3296 | }
|
---|
3297 |
|
---|
3298 | if (paramsSerializer != null) {
|
---|
3299 | if (utils$1.isFunction(paramsSerializer)) {
|
---|
3300 | config.paramsSerializer = {
|
---|
3301 | serialize: paramsSerializer
|
---|
3302 | };
|
---|
3303 | } else {
|
---|
3304 | validator.assertOptions(paramsSerializer, {
|
---|
3305 | encode: validators.function,
|
---|
3306 | serialize: validators.function
|
---|
3307 | }, true);
|
---|
3308 | }
|
---|
3309 | }
|
---|
3310 |
|
---|
3311 | // Set config.method
|
---|
3312 | config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
---|
3313 |
|
---|
3314 | // Flatten headers
|
---|
3315 | let contextHeaders = headers && utils$1.merge(
|
---|
3316 | headers.common,
|
---|
3317 | headers[config.method]
|
---|
3318 | );
|
---|
3319 |
|
---|
3320 | headers && utils$1.forEach(
|
---|
3321 | ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
---|
3322 | (method) => {
|
---|
3323 | delete headers[method];
|
---|
3324 | }
|
---|
3325 | );
|
---|
3326 |
|
---|
3327 | config.headers = AxiosHeaders$2.concat(contextHeaders, headers);
|
---|
3328 |
|
---|
3329 | // filter out skipped interceptors
|
---|
3330 | const requestInterceptorChain = [];
|
---|
3331 | let synchronousRequestInterceptors = true;
|
---|
3332 | this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
---|
3333 | if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
---|
3334 | return;
|
---|
3335 | }
|
---|
3336 |
|
---|
3337 | synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
---|
3338 |
|
---|
3339 | requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
---|
3340 | });
|
---|
3341 |
|
---|
3342 | const responseInterceptorChain = [];
|
---|
3343 | this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
---|
3344 | responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
---|
3345 | });
|
---|
3346 |
|
---|
3347 | let promise;
|
---|
3348 | let i = 0;
|
---|
3349 | let len;
|
---|
3350 |
|
---|
3351 | if (!synchronousRequestInterceptors) {
|
---|
3352 | const chain = [dispatchRequest.bind(this), undefined];
|
---|
3353 | chain.unshift.apply(chain, requestInterceptorChain);
|
---|
3354 | chain.push.apply(chain, responseInterceptorChain);
|
---|
3355 | len = chain.length;
|
---|
3356 |
|
---|
3357 | promise = Promise.resolve(config);
|
---|
3358 |
|
---|
3359 | while (i < len) {
|
---|
3360 | promise = promise.then(chain[i++], chain[i++]);
|
---|
3361 | }
|
---|
3362 |
|
---|
3363 | return promise;
|
---|
3364 | }
|
---|
3365 |
|
---|
3366 | len = requestInterceptorChain.length;
|
---|
3367 |
|
---|
3368 | let newConfig = config;
|
---|
3369 |
|
---|
3370 | i = 0;
|
---|
3371 |
|
---|
3372 | while (i < len) {
|
---|
3373 | const onFulfilled = requestInterceptorChain[i++];
|
---|
3374 | const onRejected = requestInterceptorChain[i++];
|
---|
3375 | try {
|
---|
3376 | newConfig = onFulfilled(newConfig);
|
---|
3377 | } catch (error) {
|
---|
3378 | onRejected.call(this, error);
|
---|
3379 | break;
|
---|
3380 | }
|
---|
3381 | }
|
---|
3382 |
|
---|
3383 | try {
|
---|
3384 | promise = dispatchRequest.call(this, newConfig);
|
---|
3385 | } catch (error) {
|
---|
3386 | return Promise.reject(error);
|
---|
3387 | }
|
---|
3388 |
|
---|
3389 | i = 0;
|
---|
3390 | len = responseInterceptorChain.length;
|
---|
3391 |
|
---|
3392 | while (i < len) {
|
---|
3393 | promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
---|
3394 | }
|
---|
3395 |
|
---|
3396 | return promise;
|
---|
3397 | }
|
---|
3398 |
|
---|
3399 | getUri(config) {
|
---|
3400 | config = mergeConfig$1(this.defaults, config);
|
---|
3401 | const fullPath = buildFullPath(config.baseURL, config.url);
|
---|
3402 | return buildURL(fullPath, config.params, config.paramsSerializer);
|
---|
3403 | }
|
---|
3404 | }
|
---|
3405 |
|
---|
3406 | // Provide aliases for supported request methods
|
---|
3407 | utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
---|
3408 | /*eslint func-names:0*/
|
---|
3409 | Axios$1.prototype[method] = function(url, config) {
|
---|
3410 | return this.request(mergeConfig$1(config || {}, {
|
---|
3411 | method,
|
---|
3412 | url,
|
---|
3413 | data: (config || {}).data
|
---|
3414 | }));
|
---|
3415 | };
|
---|
3416 | });
|
---|
3417 |
|
---|
3418 | utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
---|
3419 | /*eslint func-names:0*/
|
---|
3420 |
|
---|
3421 | function generateHTTPMethod(isForm) {
|
---|
3422 | return function httpMethod(url, data, config) {
|
---|
3423 | return this.request(mergeConfig$1(config || {}, {
|
---|
3424 | method,
|
---|
3425 | headers: isForm ? {
|
---|
3426 | 'Content-Type': 'multipart/form-data'
|
---|
3427 | } : {},
|
---|
3428 | url,
|
---|
3429 | data
|
---|
3430 | }));
|
---|
3431 | };
|
---|
3432 | }
|
---|
3433 |
|
---|
3434 | Axios$1.prototype[method] = generateHTTPMethod();
|
---|
3435 |
|
---|
3436 | Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
|
---|
3437 | });
|
---|
3438 |
|
---|
3439 | const Axios$2 = Axios$1;
|
---|
3440 |
|
---|
3441 | /**
|
---|
3442 | * A `CancelToken` is an object that can be used to request cancellation of an operation.
|
---|
3443 | *
|
---|
3444 | * @param {Function} executor The executor function.
|
---|
3445 | *
|
---|
3446 | * @returns {CancelToken}
|
---|
3447 | */
|
---|
3448 | class CancelToken$1 {
|
---|
3449 | constructor(executor) {
|
---|
3450 | if (typeof executor !== 'function') {
|
---|
3451 | throw new TypeError('executor must be a function.');
|
---|
3452 | }
|
---|
3453 |
|
---|
3454 | let resolvePromise;
|
---|
3455 |
|
---|
3456 | this.promise = new Promise(function promiseExecutor(resolve) {
|
---|
3457 | resolvePromise = resolve;
|
---|
3458 | });
|
---|
3459 |
|
---|
3460 | const token = this;
|
---|
3461 |
|
---|
3462 | // eslint-disable-next-line func-names
|
---|
3463 | this.promise.then(cancel => {
|
---|
3464 | if (!token._listeners) return;
|
---|
3465 |
|
---|
3466 | let i = token._listeners.length;
|
---|
3467 |
|
---|
3468 | while (i-- > 0) {
|
---|
3469 | token._listeners[i](cancel);
|
---|
3470 | }
|
---|
3471 | token._listeners = null;
|
---|
3472 | });
|
---|
3473 |
|
---|
3474 | // eslint-disable-next-line func-names
|
---|
3475 | this.promise.then = onfulfilled => {
|
---|
3476 | let _resolve;
|
---|
3477 | // eslint-disable-next-line func-names
|
---|
3478 | const promise = new Promise(resolve => {
|
---|
3479 | token.subscribe(resolve);
|
---|
3480 | _resolve = resolve;
|
---|
3481 | }).then(onfulfilled);
|
---|
3482 |
|
---|
3483 | promise.cancel = function reject() {
|
---|
3484 | token.unsubscribe(_resolve);
|
---|
3485 | };
|
---|
3486 |
|
---|
3487 | return promise;
|
---|
3488 | };
|
---|
3489 |
|
---|
3490 | executor(function cancel(message, config, request) {
|
---|
3491 | if (token.reason) {
|
---|
3492 | // Cancellation has already been requested
|
---|
3493 | return;
|
---|
3494 | }
|
---|
3495 |
|
---|
3496 | token.reason = new CanceledError$1(message, config, request);
|
---|
3497 | resolvePromise(token.reason);
|
---|
3498 | });
|
---|
3499 | }
|
---|
3500 |
|
---|
3501 | /**
|
---|
3502 | * Throws a `CanceledError` if cancellation has been requested.
|
---|
3503 | */
|
---|
3504 | throwIfRequested() {
|
---|
3505 | if (this.reason) {
|
---|
3506 | throw this.reason;
|
---|
3507 | }
|
---|
3508 | }
|
---|
3509 |
|
---|
3510 | /**
|
---|
3511 | * Subscribe to the cancel signal
|
---|
3512 | */
|
---|
3513 |
|
---|
3514 | subscribe(listener) {
|
---|
3515 | if (this.reason) {
|
---|
3516 | listener(this.reason);
|
---|
3517 | return;
|
---|
3518 | }
|
---|
3519 |
|
---|
3520 | if (this._listeners) {
|
---|
3521 | this._listeners.push(listener);
|
---|
3522 | } else {
|
---|
3523 | this._listeners = [listener];
|
---|
3524 | }
|
---|
3525 | }
|
---|
3526 |
|
---|
3527 | /**
|
---|
3528 | * Unsubscribe from the cancel signal
|
---|
3529 | */
|
---|
3530 |
|
---|
3531 | unsubscribe(listener) {
|
---|
3532 | if (!this._listeners) {
|
---|
3533 | return;
|
---|
3534 | }
|
---|
3535 | const index = this._listeners.indexOf(listener);
|
---|
3536 | if (index !== -1) {
|
---|
3537 | this._listeners.splice(index, 1);
|
---|
3538 | }
|
---|
3539 | }
|
---|
3540 |
|
---|
3541 | toAbortSignal() {
|
---|
3542 | const controller = new AbortController();
|
---|
3543 |
|
---|
3544 | const abort = (err) => {
|
---|
3545 | controller.abort(err);
|
---|
3546 | };
|
---|
3547 |
|
---|
3548 | this.subscribe(abort);
|
---|
3549 |
|
---|
3550 | controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
---|
3551 |
|
---|
3552 | return controller.signal;
|
---|
3553 | }
|
---|
3554 |
|
---|
3555 | /**
|
---|
3556 | * Returns an object that contains a new `CancelToken` and a function that, when called,
|
---|
3557 | * cancels the `CancelToken`.
|
---|
3558 | */
|
---|
3559 | static source() {
|
---|
3560 | let cancel;
|
---|
3561 | const token = new CancelToken$1(function executor(c) {
|
---|
3562 | cancel = c;
|
---|
3563 | });
|
---|
3564 | return {
|
---|
3565 | token,
|
---|
3566 | cancel
|
---|
3567 | };
|
---|
3568 | }
|
---|
3569 | }
|
---|
3570 |
|
---|
3571 | const CancelToken$2 = CancelToken$1;
|
---|
3572 |
|
---|
3573 | /**
|
---|
3574 | * Syntactic sugar for invoking a function and expanding an array for arguments.
|
---|
3575 | *
|
---|
3576 | * Common use case would be to use `Function.prototype.apply`.
|
---|
3577 | *
|
---|
3578 | * ```js
|
---|
3579 | * function f(x, y, z) {}
|
---|
3580 | * var args = [1, 2, 3];
|
---|
3581 | * f.apply(null, args);
|
---|
3582 | * ```
|
---|
3583 | *
|
---|
3584 | * With `spread` this example can be re-written.
|
---|
3585 | *
|
---|
3586 | * ```js
|
---|
3587 | * spread(function(x, y, z) {})([1, 2, 3]);
|
---|
3588 | * ```
|
---|
3589 | *
|
---|
3590 | * @param {Function} callback
|
---|
3591 | *
|
---|
3592 | * @returns {Function}
|
---|
3593 | */
|
---|
3594 | function spread$1(callback) {
|
---|
3595 | return function wrap(arr) {
|
---|
3596 | return callback.apply(null, arr);
|
---|
3597 | };
|
---|
3598 | }
|
---|
3599 |
|
---|
3600 | /**
|
---|
3601 | * Determines whether the payload is an error thrown by Axios
|
---|
3602 | *
|
---|
3603 | * @param {*} payload The value to test
|
---|
3604 | *
|
---|
3605 | * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
---|
3606 | */
|
---|
3607 | function isAxiosError$1(payload) {
|
---|
3608 | return utils$1.isObject(payload) && (payload.isAxiosError === true);
|
---|
3609 | }
|
---|
3610 |
|
---|
3611 | const HttpStatusCode$1 = {
|
---|
3612 | Continue: 100,
|
---|
3613 | SwitchingProtocols: 101,
|
---|
3614 | Processing: 102,
|
---|
3615 | EarlyHints: 103,
|
---|
3616 | Ok: 200,
|
---|
3617 | Created: 201,
|
---|
3618 | Accepted: 202,
|
---|
3619 | NonAuthoritativeInformation: 203,
|
---|
3620 | NoContent: 204,
|
---|
3621 | ResetContent: 205,
|
---|
3622 | PartialContent: 206,
|
---|
3623 | MultiStatus: 207,
|
---|
3624 | AlreadyReported: 208,
|
---|
3625 | ImUsed: 226,
|
---|
3626 | MultipleChoices: 300,
|
---|
3627 | MovedPermanently: 301,
|
---|
3628 | Found: 302,
|
---|
3629 | SeeOther: 303,
|
---|
3630 | NotModified: 304,
|
---|
3631 | UseProxy: 305,
|
---|
3632 | Unused: 306,
|
---|
3633 | TemporaryRedirect: 307,
|
---|
3634 | PermanentRedirect: 308,
|
---|
3635 | BadRequest: 400,
|
---|
3636 | Unauthorized: 401,
|
---|
3637 | PaymentRequired: 402,
|
---|
3638 | Forbidden: 403,
|
---|
3639 | NotFound: 404,
|
---|
3640 | MethodNotAllowed: 405,
|
---|
3641 | NotAcceptable: 406,
|
---|
3642 | ProxyAuthenticationRequired: 407,
|
---|
3643 | RequestTimeout: 408,
|
---|
3644 | Conflict: 409,
|
---|
3645 | Gone: 410,
|
---|
3646 | LengthRequired: 411,
|
---|
3647 | PreconditionFailed: 412,
|
---|
3648 | PayloadTooLarge: 413,
|
---|
3649 | UriTooLong: 414,
|
---|
3650 | UnsupportedMediaType: 415,
|
---|
3651 | RangeNotSatisfiable: 416,
|
---|
3652 | ExpectationFailed: 417,
|
---|
3653 | ImATeapot: 418,
|
---|
3654 | MisdirectedRequest: 421,
|
---|
3655 | UnprocessableEntity: 422,
|
---|
3656 | Locked: 423,
|
---|
3657 | FailedDependency: 424,
|
---|
3658 | TooEarly: 425,
|
---|
3659 | UpgradeRequired: 426,
|
---|
3660 | PreconditionRequired: 428,
|
---|
3661 | TooManyRequests: 429,
|
---|
3662 | RequestHeaderFieldsTooLarge: 431,
|
---|
3663 | UnavailableForLegalReasons: 451,
|
---|
3664 | InternalServerError: 500,
|
---|
3665 | NotImplemented: 501,
|
---|
3666 | BadGateway: 502,
|
---|
3667 | ServiceUnavailable: 503,
|
---|
3668 | GatewayTimeout: 504,
|
---|
3669 | HttpVersionNotSupported: 505,
|
---|
3670 | VariantAlsoNegotiates: 506,
|
---|
3671 | InsufficientStorage: 507,
|
---|
3672 | LoopDetected: 508,
|
---|
3673 | NotExtended: 510,
|
---|
3674 | NetworkAuthenticationRequired: 511,
|
---|
3675 | };
|
---|
3676 |
|
---|
3677 | Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
|
---|
3678 | HttpStatusCode$1[value] = key;
|
---|
3679 | });
|
---|
3680 |
|
---|
3681 | const HttpStatusCode$2 = HttpStatusCode$1;
|
---|
3682 |
|
---|
3683 | /**
|
---|
3684 | * Create an instance of Axios
|
---|
3685 | *
|
---|
3686 | * @param {Object} defaultConfig The default config for the instance
|
---|
3687 | *
|
---|
3688 | * @returns {Axios} A new instance of Axios
|
---|
3689 | */
|
---|
3690 | function createInstance(defaultConfig) {
|
---|
3691 | const context = new Axios$2(defaultConfig);
|
---|
3692 | const instance = bind(Axios$2.prototype.request, context);
|
---|
3693 |
|
---|
3694 | // Copy axios.prototype to instance
|
---|
3695 | utils$1.extend(instance, Axios$2.prototype, context, {allOwnKeys: true});
|
---|
3696 |
|
---|
3697 | // Copy context to instance
|
---|
3698 | utils$1.extend(instance, context, null, {allOwnKeys: true});
|
---|
3699 |
|
---|
3700 | // Factory for creating new instances
|
---|
3701 | instance.create = function create(instanceConfig) {
|
---|
3702 | return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
|
---|
3703 | };
|
---|
3704 |
|
---|
3705 | return instance;
|
---|
3706 | }
|
---|
3707 |
|
---|
3708 | // Create the default instance to be exported
|
---|
3709 | const axios = createInstance(defaults$1);
|
---|
3710 |
|
---|
3711 | // Expose Axios class to allow class inheritance
|
---|
3712 | axios.Axios = Axios$2;
|
---|
3713 |
|
---|
3714 | // Expose Cancel & CancelToken
|
---|
3715 | axios.CanceledError = CanceledError$1;
|
---|
3716 | axios.CancelToken = CancelToken$2;
|
---|
3717 | axios.isCancel = isCancel$1;
|
---|
3718 | axios.VERSION = VERSION$1;
|
---|
3719 | axios.toFormData = toFormData$1;
|
---|
3720 |
|
---|
3721 | // Expose AxiosError class
|
---|
3722 | axios.AxiosError = AxiosError$1;
|
---|
3723 |
|
---|
3724 | // alias for CanceledError for backward compatibility
|
---|
3725 | axios.Cancel = axios.CanceledError;
|
---|
3726 |
|
---|
3727 | // Expose all/spread
|
---|
3728 | axios.all = function all(promises) {
|
---|
3729 | return Promise.all(promises);
|
---|
3730 | };
|
---|
3731 |
|
---|
3732 | axios.spread = spread$1;
|
---|
3733 |
|
---|
3734 | // Expose isAxiosError
|
---|
3735 | axios.isAxiosError = isAxiosError$1;
|
---|
3736 |
|
---|
3737 | // Expose mergeConfig
|
---|
3738 | axios.mergeConfig = mergeConfig$1;
|
---|
3739 |
|
---|
3740 | axios.AxiosHeaders = AxiosHeaders$2;
|
---|
3741 |
|
---|
3742 | axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
---|
3743 |
|
---|
3744 | axios.getAdapter = adapters.getAdapter;
|
---|
3745 |
|
---|
3746 | axios.HttpStatusCode = HttpStatusCode$2;
|
---|
3747 |
|
---|
3748 | axios.default = axios;
|
---|
3749 |
|
---|
3750 | // this module should only have a default export
|
---|
3751 | const axios$1 = axios;
|
---|
3752 |
|
---|
3753 | // This module is intended to unwrap Axios default export as named.
|
---|
3754 | // Keep top-level export same with static properties
|
---|
3755 | // so that it can keep same with es module or cjs
|
---|
3756 | const {
|
---|
3757 | Axios,
|
---|
3758 | AxiosError,
|
---|
3759 | CanceledError,
|
---|
3760 | isCancel,
|
---|
3761 | CancelToken,
|
---|
3762 | VERSION,
|
---|
3763 | all,
|
---|
3764 | Cancel,
|
---|
3765 | isAxiosError,
|
---|
3766 | spread,
|
---|
3767 | toFormData,
|
---|
3768 | AxiosHeaders,
|
---|
3769 | HttpStatusCode,
|
---|
3770 | formToJSON,
|
---|
3771 | getAdapter,
|
---|
3772 | mergeConfig
|
---|
3773 | } = axios$1;
|
---|
3774 |
|
---|
3775 | export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, axios$1 as default, formToJSON, getAdapter, isAxiosError, isCancel, mergeConfig, spread, toFormData };
|
---|
3776 | //# sourceMappingURL=axios.js.map
|
---|