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