axios 0.27.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

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