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