Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/axios/dist/axios.js
1126 views
1
(function webpackUniversalModuleDefinition(root, factory) {
2
if(typeof exports === 'object' && typeof module === 'object')
3
module.exports = factory();
4
else if(typeof define === 'function' && define.amd)
5
define([], factory);
6
else if(typeof exports === 'object')
7
exports["axios"] = factory();
8
else
9
root["axios"] = factory();
10
})(this, function() {
11
return /******/ (function(modules) { // webpackBootstrap
12
/******/ // The module cache
13
/******/ var installedModules = {};
14
/******/
15
/******/ // The require function
16
/******/ function __webpack_require__(moduleId) {
17
/******/
18
/******/ // Check if module is in cache
19
/******/ if(installedModules[moduleId]) {
20
/******/ return installedModules[moduleId].exports;
21
/******/ }
22
/******/ // Create a new module (and put it into the cache)
23
/******/ var module = installedModules[moduleId] = {
24
/******/ i: moduleId,
25
/******/ l: false,
26
/******/ exports: {}
27
/******/ };
28
/******/
29
/******/ // Execute the module function
30
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
/******/
32
/******/ // Flag the module as loaded
33
/******/ module.l = true;
34
/******/
35
/******/ // Return the exports of the module
36
/******/ return module.exports;
37
/******/ }
38
/******/
39
/******/
40
/******/ // expose the modules object (__webpack_modules__)
41
/******/ __webpack_require__.m = modules;
42
/******/
43
/******/ // expose the module cache
44
/******/ __webpack_require__.c = installedModules;
45
/******/
46
/******/ // define getter function for harmony exports
47
/******/ __webpack_require__.d = function(exports, name, getter) {
48
/******/ if(!__webpack_require__.o(exports, name)) {
49
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50
/******/ }
51
/******/ };
52
/******/
53
/******/ // define __esModule on exports
54
/******/ __webpack_require__.r = function(exports) {
55
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57
/******/ }
58
/******/ Object.defineProperty(exports, '__esModule', { value: true });
59
/******/ };
60
/******/
61
/******/ // create a fake namespace object
62
/******/ // mode & 1: value is a module id, require it
63
/******/ // mode & 2: merge all properties of value into the ns
64
/******/ // mode & 4: return value when already ns object
65
/******/ // mode & 8|1: behave like require
66
/******/ __webpack_require__.t = function(value, mode) {
67
/******/ if(mode & 1) value = __webpack_require__(value);
68
/******/ if(mode & 8) return value;
69
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70
/******/ var ns = Object.create(null);
71
/******/ __webpack_require__.r(ns);
72
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74
/******/ return ns;
75
/******/ };
76
/******/
77
/******/ // getDefaultExport function for compatibility with non-harmony modules
78
/******/ __webpack_require__.n = function(module) {
79
/******/ var getter = module && module.__esModule ?
80
/******/ function getDefault() { return module['default']; } :
81
/******/ function getModuleExports() { return module; };
82
/******/ __webpack_require__.d(getter, 'a', getter);
83
/******/ return getter;
84
/******/ };
85
/******/
86
/******/ // Object.prototype.hasOwnProperty.call
87
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88
/******/
89
/******/ // __webpack_public_path__
90
/******/ __webpack_require__.p = "";
91
/******/
92
/******/
93
/******/ // Load entry module and return exports
94
/******/ return __webpack_require__(__webpack_require__.s = "./index.js");
95
/******/ })
96
/************************************************************************/
97
/******/ ({
98
99
/***/ "./index.js":
100
/*!******************!*\
101
!*** ./index.js ***!
102
\******************/
103
/*! no static exports found */
104
/***/ (function(module, exports, __webpack_require__) {
105
106
module.exports = __webpack_require__(/*! ./lib/axios */ "./lib/axios.js");
107
108
/***/ }),
109
110
/***/ "./lib/adapters/xhr.js":
111
/*!*****************************!*\
112
!*** ./lib/adapters/xhr.js ***!
113
\*****************************/
114
/*! no static exports found */
115
/***/ (function(module, exports, __webpack_require__) {
116
117
"use strict";
118
119
120
var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
121
var settle = __webpack_require__(/*! ./../core/settle */ "./lib/core/settle.js");
122
var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./lib/helpers/cookies.js");
123
var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./lib/helpers/buildURL.js");
124
var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./lib/core/buildFullPath.js");
125
var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./lib/helpers/parseHeaders.js");
126
var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./lib/helpers/isURLSameOrigin.js");
127
var createError = __webpack_require__(/*! ../core/createError */ "./lib/core/createError.js");
128
var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults.js");
129
var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./lib/cancel/Cancel.js");
130
131
module.exports = function xhrAdapter(config) {
132
return new Promise(function dispatchXhrRequest(resolve, reject) {
133
var requestData = config.data;
134
var requestHeaders = config.headers;
135
var responseType = config.responseType;
136
var onCanceled;
137
function done() {
138
if (config.cancelToken) {
139
config.cancelToken.unsubscribe(onCanceled);
140
}
141
142
if (config.signal) {
143
config.signal.removeEventListener('abort', onCanceled);
144
}
145
}
146
147
if (utils.isFormData(requestData)) {
148
delete requestHeaders['Content-Type']; // Let the browser set it
149
}
150
151
var request = new XMLHttpRequest();
152
153
// HTTP basic authentication
154
if (config.auth) {
155
var username = config.auth.username || '';
156
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
157
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
158
}
159
160
var fullPath = buildFullPath(config.baseURL, config.url);
161
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
162
163
// Set the request timeout in MS
164
request.timeout = config.timeout;
165
166
function onloadend() {
167
if (!request) {
168
return;
169
}
170
// Prepare the response
171
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
172
var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
173
request.responseText : request.response;
174
var response = {
175
data: responseData,
176
status: request.status,
177
statusText: request.statusText,
178
headers: responseHeaders,
179
config: config,
180
request: request
181
};
182
183
settle(function _resolve(value) {
184
resolve(value);
185
done();
186
}, function _reject(err) {
187
reject(err);
188
done();
189
}, response);
190
191
// Clean up request
192
request = null;
193
}
194
195
if ('onloadend' in request) {
196
// Use onloadend if available
197
request.onloadend = onloadend;
198
} else {
199
// Listen for ready state to emulate onloadend
200
request.onreadystatechange = function handleLoad() {
201
if (!request || request.readyState !== 4) {
202
return;
203
}
204
205
// The request errored out and we didn't get a response, this will be
206
// handled by onerror instead
207
// With one exception: request that using file: protocol, most browsers
208
// will return status as 0 even though it's a successful request
209
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
210
return;
211
}
212
// readystate handler is calling before onerror or ontimeout handlers,
213
// so we should call onloadend on the next 'tick'
214
setTimeout(onloadend);
215
};
216
}
217
218
// Handle browser request cancellation (as opposed to a manual cancellation)
219
request.onabort = function handleAbort() {
220
if (!request) {
221
return;
222
}
223
224
reject(createError('Request aborted', config, 'ECONNABORTED', request));
225
226
// Clean up request
227
request = null;
228
};
229
230
// Handle low level network errors
231
request.onerror = function handleError() {
232
// Real errors are hidden from us by the browser
233
// onerror should only fire if it's a network error
234
reject(createError('Network Error', config, null, request));
235
236
// Clean up request
237
request = null;
238
};
239
240
// Handle timeout
241
request.ontimeout = function handleTimeout() {
242
var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
243
var transitional = config.transitional || defaults.transitional;
244
if (config.timeoutErrorMessage) {
245
timeoutErrorMessage = config.timeoutErrorMessage;
246
}
247
reject(createError(
248
timeoutErrorMessage,
249
config,
250
transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
251
request));
252
253
// Clean up request
254
request = null;
255
};
256
257
// Add xsrf header
258
// This is only done if running in a standard browser environment.
259
// Specifically not if we're in a web worker, or react-native.
260
if (utils.isStandardBrowserEnv()) {
261
// Add xsrf header
262
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
263
cookies.read(config.xsrfCookieName) :
264
undefined;
265
266
if (xsrfValue) {
267
requestHeaders[config.xsrfHeaderName] = xsrfValue;
268
}
269
}
270
271
// Add headers to the request
272
if ('setRequestHeader' in request) {
273
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
274
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
275
// Remove Content-Type if data is undefined
276
delete requestHeaders[key];
277
} else {
278
// Otherwise add header to the request
279
request.setRequestHeader(key, val);
280
}
281
});
282
}
283
284
// Add withCredentials to request if needed
285
if (!utils.isUndefined(config.withCredentials)) {
286
request.withCredentials = !!config.withCredentials;
287
}
288
289
// Add responseType to request if needed
290
if (responseType && responseType !== 'json') {
291
request.responseType = config.responseType;
292
}
293
294
// Handle progress if needed
295
if (typeof config.onDownloadProgress === 'function') {
296
request.addEventListener('progress', config.onDownloadProgress);
297
}
298
299
// Not all browsers support upload events
300
if (typeof config.onUploadProgress === 'function' && request.upload) {
301
request.upload.addEventListener('progress', config.onUploadProgress);
302
}
303
304
if (config.cancelToken || config.signal) {
305
// Handle cancellation
306
// eslint-disable-next-line func-names
307
onCanceled = function(cancel) {
308
if (!request) {
309
return;
310
}
311
reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
312
request.abort();
313
request = null;
314
};
315
316
config.cancelToken && config.cancelToken.subscribe(onCanceled);
317
if (config.signal) {
318
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
319
}
320
}
321
322
if (!requestData) {
323
requestData = null;
324
}
325
326
// Send the request
327
request.send(requestData);
328
});
329
};
330
331
332
/***/ }),
333
334
/***/ "./lib/axios.js":
335
/*!**********************!*\
336
!*** ./lib/axios.js ***!
337
\**********************/
338
/*! no static exports found */
339
/***/ (function(module, exports, __webpack_require__) {
340
341
"use strict";
342
343
344
var utils = __webpack_require__(/*! ./utils */ "./lib/utils.js");
345
var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
346
var Axios = __webpack_require__(/*! ./core/Axios */ "./lib/core/Axios.js");
347
var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./lib/core/mergeConfig.js");
348
var defaults = __webpack_require__(/*! ./defaults */ "./lib/defaults.js");
349
350
/**
351
* Create an instance of Axios
352
*
353
* @param {Object} defaultConfig The default config for the instance
354
* @return {Axios} A new instance of Axios
355
*/
356
function createInstance(defaultConfig) {
357
var context = new Axios(defaultConfig);
358
var instance = bind(Axios.prototype.request, context);
359
360
// Copy axios.prototype to instance
361
utils.extend(instance, Axios.prototype, context);
362
363
// Copy context to instance
364
utils.extend(instance, context);
365
366
// Factory for creating new instances
367
instance.create = function create(instanceConfig) {
368
return createInstance(mergeConfig(defaultConfig, instanceConfig));
369
};
370
371
return instance;
372
}
373
374
// Create the default instance to be exported
375
var axios = createInstance(defaults);
376
377
// Expose Axios class to allow class inheritance
378
axios.Axios = Axios;
379
380
// Expose Cancel & CancelToken
381
axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./lib/cancel/Cancel.js");
382
axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./lib/cancel/CancelToken.js");
383
axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./lib/cancel/isCancel.js");
384
axios.VERSION = __webpack_require__(/*! ./env/data */ "./lib/env/data.js").version;
385
386
// Expose all/spread
387
axios.all = function all(promises) {
388
return Promise.all(promises);
389
};
390
axios.spread = __webpack_require__(/*! ./helpers/spread */ "./lib/helpers/spread.js");
391
392
// Expose isAxiosError
393
axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./lib/helpers/isAxiosError.js");
394
395
module.exports = axios;
396
397
// Allow use of default import syntax in TypeScript
398
module.exports.default = axios;
399
400
401
/***/ }),
402
403
/***/ "./lib/cancel/Cancel.js":
404
/*!******************************!*\
405
!*** ./lib/cancel/Cancel.js ***!
406
\******************************/
407
/*! no static exports found */
408
/***/ (function(module, exports, __webpack_require__) {
409
410
"use strict";
411
412
413
/**
414
* A `Cancel` is an object that is thrown when an operation is canceled.
415
*
416
* @class
417
* @param {string=} message The message.
418
*/
419
function Cancel(message) {
420
this.message = message;
421
}
422
423
Cancel.prototype.toString = function toString() {
424
return 'Cancel' + (this.message ? ': ' + this.message : '');
425
};
426
427
Cancel.prototype.__CANCEL__ = true;
428
429
module.exports = Cancel;
430
431
432
/***/ }),
433
434
/***/ "./lib/cancel/CancelToken.js":
435
/*!***********************************!*\
436
!*** ./lib/cancel/CancelToken.js ***!
437
\***********************************/
438
/*! no static exports found */
439
/***/ (function(module, exports, __webpack_require__) {
440
441
"use strict";
442
443
444
var Cancel = __webpack_require__(/*! ./Cancel */ "./lib/cancel/Cancel.js");
445
446
/**
447
* A `CancelToken` is an object that can be used to request cancellation of an operation.
448
*
449
* @class
450
* @param {Function} executor The executor function.
451
*/
452
function CancelToken(executor) {
453
if (typeof executor !== 'function') {
454
throw new TypeError('executor must be a function.');
455
}
456
457
var resolvePromise;
458
459
this.promise = new Promise(function promiseExecutor(resolve) {
460
resolvePromise = resolve;
461
});
462
463
var token = this;
464
465
// eslint-disable-next-line func-names
466
this.promise.then(function(cancel) {
467
if (!token._listeners) return;
468
469
var i;
470
var l = token._listeners.length;
471
472
for (i = 0; i < l; i++) {
473
token._listeners[i](cancel);
474
}
475
token._listeners = null;
476
});
477
478
// eslint-disable-next-line func-names
479
this.promise.then = function(onfulfilled) {
480
var _resolve;
481
// eslint-disable-next-line func-names
482
var promise = new Promise(function(resolve) {
483
token.subscribe(resolve);
484
_resolve = resolve;
485
}).then(onfulfilled);
486
487
promise.cancel = function reject() {
488
token.unsubscribe(_resolve);
489
};
490
491
return promise;
492
};
493
494
executor(function cancel(message) {
495
if (token.reason) {
496
// Cancellation has already been requested
497
return;
498
}
499
500
token.reason = new Cancel(message);
501
resolvePromise(token.reason);
502
});
503
}
504
505
/**
506
* Throws a `Cancel` if cancellation has been requested.
507
*/
508
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
509
if (this.reason) {
510
throw this.reason;
511
}
512
};
513
514
/**
515
* Subscribe to the cancel signal
516
*/
517
518
CancelToken.prototype.subscribe = function subscribe(listener) {
519
if (this.reason) {
520
listener(this.reason);
521
return;
522
}
523
524
if (this._listeners) {
525
this._listeners.push(listener);
526
} else {
527
this._listeners = [listener];
528
}
529
};
530
531
/**
532
* Unsubscribe from the cancel signal
533
*/
534
535
CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
536
if (!this._listeners) {
537
return;
538
}
539
var index = this._listeners.indexOf(listener);
540
if (index !== -1) {
541
this._listeners.splice(index, 1);
542
}
543
};
544
545
/**
546
* Returns an object that contains a new `CancelToken` and a function that, when called,
547
* cancels the `CancelToken`.
548
*/
549
CancelToken.source = function source() {
550
var cancel;
551
var token = new CancelToken(function executor(c) {
552
cancel = c;
553
});
554
return {
555
token: token,
556
cancel: cancel
557
};
558
};
559
560
module.exports = CancelToken;
561
562
563
/***/ }),
564
565
/***/ "./lib/cancel/isCancel.js":
566
/*!********************************!*\
567
!*** ./lib/cancel/isCancel.js ***!
568
\********************************/
569
/*! no static exports found */
570
/***/ (function(module, exports, __webpack_require__) {
571
572
"use strict";
573
574
575
module.exports = function isCancel(value) {
576
return !!(value && value.__CANCEL__);
577
};
578
579
580
/***/ }),
581
582
/***/ "./lib/core/Axios.js":
583
/*!***************************!*\
584
!*** ./lib/core/Axios.js ***!
585
\***************************/
586
/*! no static exports found */
587
/***/ (function(module, exports, __webpack_require__) {
588
589
"use strict";
590
591
592
var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
593
var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./lib/helpers/buildURL.js");
594
var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./lib/core/InterceptorManager.js");
595
var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./lib/core/dispatchRequest.js");
596
var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./lib/core/mergeConfig.js");
597
var validator = __webpack_require__(/*! ../helpers/validator */ "./lib/helpers/validator.js");
598
599
var validators = validator.validators;
600
/**
601
* Create a new instance of Axios
602
*
603
* @param {Object} instanceConfig The default config for the instance
604
*/
605
function Axios(instanceConfig) {
606
this.defaults = instanceConfig;
607
this.interceptors = {
608
request: new InterceptorManager(),
609
response: new InterceptorManager()
610
};
611
}
612
613
/**
614
* Dispatch a request
615
*
616
* @param {Object} config The config specific for this request (merged with this.defaults)
617
*/
618
Axios.prototype.request = function request(config) {
619
/*eslint no-param-reassign:0*/
620
// Allow for axios('example/url'[, config]) a la fetch API
621
if (typeof config === 'string') {
622
config = arguments[1] || {};
623
config.url = arguments[0];
624
} else {
625
config = config || {};
626
}
627
628
config = mergeConfig(this.defaults, config);
629
630
// Set config.method
631
if (config.method) {
632
config.method = config.method.toLowerCase();
633
} else if (this.defaults.method) {
634
config.method = this.defaults.method.toLowerCase();
635
} else {
636
config.method = 'get';
637
}
638
639
var transitional = config.transitional;
640
641
if (transitional !== undefined) {
642
validator.assertOptions(transitional, {
643
silentJSONParsing: validators.transitional(validators.boolean),
644
forcedJSONParsing: validators.transitional(validators.boolean),
645
clarifyTimeoutError: validators.transitional(validators.boolean)
646
}, false);
647
}
648
649
// filter out skipped interceptors
650
var requestInterceptorChain = [];
651
var synchronousRequestInterceptors = true;
652
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
653
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
654
return;
655
}
656
657
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
658
659
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
660
});
661
662
var responseInterceptorChain = [];
663
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
664
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
665
});
666
667
var promise;
668
669
if (!synchronousRequestInterceptors) {
670
var chain = [dispatchRequest, undefined];
671
672
Array.prototype.unshift.apply(chain, requestInterceptorChain);
673
chain = chain.concat(responseInterceptorChain);
674
675
promise = Promise.resolve(config);
676
while (chain.length) {
677
promise = promise.then(chain.shift(), chain.shift());
678
}
679
680
return promise;
681
}
682
683
684
var newConfig = config;
685
while (requestInterceptorChain.length) {
686
var onFulfilled = requestInterceptorChain.shift();
687
var onRejected = requestInterceptorChain.shift();
688
try {
689
newConfig = onFulfilled(newConfig);
690
} catch (error) {
691
onRejected(error);
692
break;
693
}
694
}
695
696
try {
697
promise = dispatchRequest(newConfig);
698
} catch (error) {
699
return Promise.reject(error);
700
}
701
702
while (responseInterceptorChain.length) {
703
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
704
}
705
706
return promise;
707
};
708
709
Axios.prototype.getUri = function getUri(config) {
710
config = mergeConfig(this.defaults, config);
711
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
712
};
713
714
// Provide aliases for supported request methods
715
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
716
/*eslint func-names:0*/
717
Axios.prototype[method] = function(url, config) {
718
return this.request(mergeConfig(config || {}, {
719
method: method,
720
url: url,
721
data: (config || {}).data
722
}));
723
};
724
});
725
726
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
727
/*eslint func-names:0*/
728
Axios.prototype[method] = function(url, data, config) {
729
return this.request(mergeConfig(config || {}, {
730
method: method,
731
url: url,
732
data: data
733
}));
734
};
735
});
736
737
module.exports = Axios;
738
739
740
/***/ }),
741
742
/***/ "./lib/core/InterceptorManager.js":
743
/*!****************************************!*\
744
!*** ./lib/core/InterceptorManager.js ***!
745
\****************************************/
746
/*! no static exports found */
747
/***/ (function(module, exports, __webpack_require__) {
748
749
"use strict";
750
751
752
var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
753
754
function InterceptorManager() {
755
this.handlers = [];
756
}
757
758
/**
759
* Add a new interceptor to the stack
760
*
761
* @param {Function} fulfilled The function to handle `then` for a `Promise`
762
* @param {Function} rejected The function to handle `reject` for a `Promise`
763
*
764
* @return {Number} An ID used to remove interceptor later
765
*/
766
InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
767
this.handlers.push({
768
fulfilled: fulfilled,
769
rejected: rejected,
770
synchronous: options ? options.synchronous : false,
771
runWhen: options ? options.runWhen : null
772
});
773
return this.handlers.length - 1;
774
};
775
776
/**
777
* Remove an interceptor from the stack
778
*
779
* @param {Number} id The ID that was returned by `use`
780
*/
781
InterceptorManager.prototype.eject = function eject(id) {
782
if (this.handlers[id]) {
783
this.handlers[id] = null;
784
}
785
};
786
787
/**
788
* Iterate over all the registered interceptors
789
*
790
* This method is particularly useful for skipping over any
791
* interceptors that may have become `null` calling `eject`.
792
*
793
* @param {Function} fn The function to call for each interceptor
794
*/
795
InterceptorManager.prototype.forEach = function forEach(fn) {
796
utils.forEach(this.handlers, function forEachHandler(h) {
797
if (h !== null) {
798
fn(h);
799
}
800
});
801
};
802
803
module.exports = InterceptorManager;
804
805
806
/***/ }),
807
808
/***/ "./lib/core/buildFullPath.js":
809
/*!***********************************!*\
810
!*** ./lib/core/buildFullPath.js ***!
811
\***********************************/
812
/*! no static exports found */
813
/***/ (function(module, exports, __webpack_require__) {
814
815
"use strict";
816
817
818
var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./lib/helpers/isAbsoluteURL.js");
819
var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./lib/helpers/combineURLs.js");
820
821
/**
822
* Creates a new URL by combining the baseURL with the requestedURL,
823
* only when the requestedURL is not already an absolute URL.
824
* If the requestURL is absolute, this function returns the requestedURL untouched.
825
*
826
* @param {string} baseURL The base URL
827
* @param {string} requestedURL Absolute or relative URL to combine
828
* @returns {string} The combined full path
829
*/
830
module.exports = function buildFullPath(baseURL, requestedURL) {
831
if (baseURL && !isAbsoluteURL(requestedURL)) {
832
return combineURLs(baseURL, requestedURL);
833
}
834
return requestedURL;
835
};
836
837
838
/***/ }),
839
840
/***/ "./lib/core/createError.js":
841
/*!*********************************!*\
842
!*** ./lib/core/createError.js ***!
843
\*********************************/
844
/*! no static exports found */
845
/***/ (function(module, exports, __webpack_require__) {
846
847
"use strict";
848
849
850
var enhanceError = __webpack_require__(/*! ./enhanceError */ "./lib/core/enhanceError.js");
851
852
/**
853
* Create an Error with the specified message, config, error code, request and response.
854
*
855
* @param {string} message The error message.
856
* @param {Object} config The config.
857
* @param {string} [code] The error code (for example, 'ECONNABORTED').
858
* @param {Object} [request] The request.
859
* @param {Object} [response] The response.
860
* @returns {Error} The created error.
861
*/
862
module.exports = function createError(message, config, code, request, response) {
863
var error = new Error(message);
864
return enhanceError(error, config, code, request, response);
865
};
866
867
868
/***/ }),
869
870
/***/ "./lib/core/dispatchRequest.js":
871
/*!*************************************!*\
872
!*** ./lib/core/dispatchRequest.js ***!
873
\*************************************/
874
/*! no static exports found */
875
/***/ (function(module, exports, __webpack_require__) {
876
877
"use strict";
878
879
880
var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
881
var transformData = __webpack_require__(/*! ./transformData */ "./lib/core/transformData.js");
882
var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./lib/cancel/isCancel.js");
883
var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults.js");
884
var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./lib/cancel/Cancel.js");
885
886
/**
887
* Throws a `Cancel` if cancellation has been requested.
888
*/
889
function throwIfCancellationRequested(config) {
890
if (config.cancelToken) {
891
config.cancelToken.throwIfRequested();
892
}
893
894
if (config.signal && config.signal.aborted) {
895
throw new Cancel('canceled');
896
}
897
}
898
899
/**
900
* Dispatch a request to the server using the configured adapter.
901
*
902
* @param {object} config The config that is to be used for the request
903
* @returns {Promise} The Promise to be fulfilled
904
*/
905
module.exports = function dispatchRequest(config) {
906
throwIfCancellationRequested(config);
907
908
// Ensure headers exist
909
config.headers = config.headers || {};
910
911
// Transform request data
912
config.data = transformData.call(
913
config,
914
config.data,
915
config.headers,
916
config.transformRequest
917
);
918
919
// Flatten headers
920
config.headers = utils.merge(
921
config.headers.common || {},
922
config.headers[config.method] || {},
923
config.headers
924
);
925
926
utils.forEach(
927
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
928
function cleanHeaderConfig(method) {
929
delete config.headers[method];
930
}
931
);
932
933
var adapter = config.adapter || defaults.adapter;
934
935
return adapter(config).then(function onAdapterResolution(response) {
936
throwIfCancellationRequested(config);
937
938
// Transform response data
939
response.data = transformData.call(
940
config,
941
response.data,
942
response.headers,
943
config.transformResponse
944
);
945
946
return response;
947
}, function onAdapterRejection(reason) {
948
if (!isCancel(reason)) {
949
throwIfCancellationRequested(config);
950
951
// Transform response data
952
if (reason && reason.response) {
953
reason.response.data = transformData.call(
954
config,
955
reason.response.data,
956
reason.response.headers,
957
config.transformResponse
958
);
959
}
960
}
961
962
return Promise.reject(reason);
963
});
964
};
965
966
967
/***/ }),
968
969
/***/ "./lib/core/enhanceError.js":
970
/*!**********************************!*\
971
!*** ./lib/core/enhanceError.js ***!
972
\**********************************/
973
/*! no static exports found */
974
/***/ (function(module, exports, __webpack_require__) {
975
976
"use strict";
977
978
979
/**
980
* Update an Error with the specified config, error code, and response.
981
*
982
* @param {Error} error The error to update.
983
* @param {Object} config The config.
984
* @param {string} [code] The error code (for example, 'ECONNABORTED').
985
* @param {Object} [request] The request.
986
* @param {Object} [response] The response.
987
* @returns {Error} The error.
988
*/
989
module.exports = function enhanceError(error, config, code, request, response) {
990
error.config = config;
991
if (code) {
992
error.code = code;
993
}
994
995
error.request = request;
996
error.response = response;
997
error.isAxiosError = true;
998
999
error.toJSON = function toJSON() {
1000
return {
1001
// Standard
1002
message: this.message,
1003
name: this.name,
1004
// Microsoft
1005
description: this.description,
1006
number: this.number,
1007
// Mozilla
1008
fileName: this.fileName,
1009
lineNumber: this.lineNumber,
1010
columnNumber: this.columnNumber,
1011
stack: this.stack,
1012
// Axios
1013
config: this.config,
1014
code: this.code,
1015
status: this.response && this.response.status ? this.response.status : null
1016
};
1017
};
1018
return error;
1019
};
1020
1021
1022
/***/ }),
1023
1024
/***/ "./lib/core/mergeConfig.js":
1025
/*!*********************************!*\
1026
!*** ./lib/core/mergeConfig.js ***!
1027
\*********************************/
1028
/*! no static exports found */
1029
/***/ (function(module, exports, __webpack_require__) {
1030
1031
"use strict";
1032
1033
1034
var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
1035
1036
/**
1037
* Config-specific merge-function which creates a new config-object
1038
* by merging two configuration objects together.
1039
*
1040
* @param {Object} config1
1041
* @param {Object} config2
1042
* @returns {Object} New object resulting from merging config2 to config1
1043
*/
1044
module.exports = function mergeConfig(config1, config2) {
1045
// eslint-disable-next-line no-param-reassign
1046
config2 = config2 || {};
1047
var config = {};
1048
1049
function getMergedValue(target, source) {
1050
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
1051
return utils.merge(target, source);
1052
} else if (utils.isPlainObject(source)) {
1053
return utils.merge({}, source);
1054
} else if (utils.isArray(source)) {
1055
return source.slice();
1056
}
1057
return source;
1058
}
1059
1060
// eslint-disable-next-line consistent-return
1061
function mergeDeepProperties(prop) {
1062
if (!utils.isUndefined(config2[prop])) {
1063
return getMergedValue(config1[prop], config2[prop]);
1064
} else if (!utils.isUndefined(config1[prop])) {
1065
return getMergedValue(undefined, config1[prop]);
1066
}
1067
}
1068
1069
// eslint-disable-next-line consistent-return
1070
function valueFromConfig2(prop) {
1071
if (!utils.isUndefined(config2[prop])) {
1072
return getMergedValue(undefined, config2[prop]);
1073
}
1074
}
1075
1076
// eslint-disable-next-line consistent-return
1077
function defaultToConfig2(prop) {
1078
if (!utils.isUndefined(config2[prop])) {
1079
return getMergedValue(undefined, config2[prop]);
1080
} else if (!utils.isUndefined(config1[prop])) {
1081
return getMergedValue(undefined, config1[prop]);
1082
}
1083
}
1084
1085
// eslint-disable-next-line consistent-return
1086
function mergeDirectKeys(prop) {
1087
if (prop in config2) {
1088
return getMergedValue(config1[prop], config2[prop]);
1089
} else if (prop in config1) {
1090
return getMergedValue(undefined, config1[prop]);
1091
}
1092
}
1093
1094
var mergeMap = {
1095
'url': valueFromConfig2,
1096
'method': valueFromConfig2,
1097
'data': valueFromConfig2,
1098
'baseURL': defaultToConfig2,
1099
'transformRequest': defaultToConfig2,
1100
'transformResponse': defaultToConfig2,
1101
'paramsSerializer': defaultToConfig2,
1102
'timeout': defaultToConfig2,
1103
'timeoutMessage': defaultToConfig2,
1104
'withCredentials': defaultToConfig2,
1105
'adapter': defaultToConfig2,
1106
'responseType': defaultToConfig2,
1107
'xsrfCookieName': defaultToConfig2,
1108
'xsrfHeaderName': defaultToConfig2,
1109
'onUploadProgress': defaultToConfig2,
1110
'onDownloadProgress': defaultToConfig2,
1111
'decompress': defaultToConfig2,
1112
'maxContentLength': defaultToConfig2,
1113
'maxBodyLength': defaultToConfig2,
1114
'transport': defaultToConfig2,
1115
'httpAgent': defaultToConfig2,
1116
'httpsAgent': defaultToConfig2,
1117
'cancelToken': defaultToConfig2,
1118
'socketPath': defaultToConfig2,
1119
'responseEncoding': defaultToConfig2,
1120
'validateStatus': mergeDirectKeys
1121
};
1122
1123
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
1124
var merge = mergeMap[prop] || mergeDeepProperties;
1125
var configValue = merge(prop);
1126
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
1127
});
1128
1129
return config;
1130
};
1131
1132
1133
/***/ }),
1134
1135
/***/ "./lib/core/settle.js":
1136
/*!****************************!*\
1137
!*** ./lib/core/settle.js ***!
1138
\****************************/
1139
/*! no static exports found */
1140
/***/ (function(module, exports, __webpack_require__) {
1141
1142
"use strict";
1143
1144
1145
var createError = __webpack_require__(/*! ./createError */ "./lib/core/createError.js");
1146
1147
/**
1148
* Resolve or reject a Promise based on response status.
1149
*
1150
* @param {Function} resolve A function that resolves the promise.
1151
* @param {Function} reject A function that rejects the promise.
1152
* @param {object} response The response.
1153
*/
1154
module.exports = function settle(resolve, reject, response) {
1155
var validateStatus = response.config.validateStatus;
1156
if (!response.status || !validateStatus || validateStatus(response.status)) {
1157
resolve(response);
1158
} else {
1159
reject(createError(
1160
'Request failed with status code ' + response.status,
1161
response.config,
1162
null,
1163
response.request,
1164
response
1165
));
1166
}
1167
};
1168
1169
1170
/***/ }),
1171
1172
/***/ "./lib/core/transformData.js":
1173
/*!***********************************!*\
1174
!*** ./lib/core/transformData.js ***!
1175
\***********************************/
1176
/*! no static exports found */
1177
/***/ (function(module, exports, __webpack_require__) {
1178
1179
"use strict";
1180
1181
1182
var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
1183
var defaults = __webpack_require__(/*! ./../defaults */ "./lib/defaults.js");
1184
1185
/**
1186
* Transform the data for a request or a response
1187
*
1188
* @param {Object|String} data The data to be transformed
1189
* @param {Array} headers The headers for the request or response
1190
* @param {Array|Function} fns A single function or Array of functions
1191
* @returns {*} The resulting transformed data
1192
*/
1193
module.exports = function transformData(data, headers, fns) {
1194
var context = this || defaults;
1195
/*eslint no-param-reassign:0*/
1196
utils.forEach(fns, function transform(fn) {
1197
data = fn.call(context, data, headers);
1198
});
1199
1200
return data;
1201
};
1202
1203
1204
/***/ }),
1205
1206
/***/ "./lib/defaults.js":
1207
/*!*************************!*\
1208
!*** ./lib/defaults.js ***!
1209
\*************************/
1210
/*! no static exports found */
1211
/***/ (function(module, exports, __webpack_require__) {
1212
1213
"use strict";
1214
1215
1216
var utils = __webpack_require__(/*! ./utils */ "./lib/utils.js");
1217
var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./lib/helpers/normalizeHeaderName.js");
1218
var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./lib/core/enhanceError.js");
1219
1220
var DEFAULT_CONTENT_TYPE = {
1221
'Content-Type': 'application/x-www-form-urlencoded'
1222
};
1223
1224
function setContentTypeIfUnset(headers, value) {
1225
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
1226
headers['Content-Type'] = value;
1227
}
1228
}
1229
1230
function getDefaultAdapter() {
1231
var adapter;
1232
if (typeof XMLHttpRequest !== 'undefined') {
1233
// For browsers use XHR adapter
1234
adapter = __webpack_require__(/*! ./adapters/xhr */ "./lib/adapters/xhr.js");
1235
} else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
1236
// For node use HTTP adapter
1237
adapter = __webpack_require__(/*! ./adapters/http */ "./lib/adapters/xhr.js");
1238
}
1239
return adapter;
1240
}
1241
1242
function stringifySafely(rawValue, parser, encoder) {
1243
if (utils.isString(rawValue)) {
1244
try {
1245
(parser || JSON.parse)(rawValue);
1246
return utils.trim(rawValue);
1247
} catch (e) {
1248
if (e.name !== 'SyntaxError') {
1249
throw e;
1250
}
1251
}
1252
}
1253
1254
return (encoder || JSON.stringify)(rawValue);
1255
}
1256
1257
var defaults = {
1258
1259
transitional: {
1260
silentJSONParsing: true,
1261
forcedJSONParsing: true,
1262
clarifyTimeoutError: false
1263
},
1264
1265
adapter: getDefaultAdapter(),
1266
1267
transformRequest: [function transformRequest(data, headers) {
1268
normalizeHeaderName(headers, 'Accept');
1269
normalizeHeaderName(headers, 'Content-Type');
1270
1271
if (utils.isFormData(data) ||
1272
utils.isArrayBuffer(data) ||
1273
utils.isBuffer(data) ||
1274
utils.isStream(data) ||
1275
utils.isFile(data) ||
1276
utils.isBlob(data)
1277
) {
1278
return data;
1279
}
1280
if (utils.isArrayBufferView(data)) {
1281
return data.buffer;
1282
}
1283
if (utils.isURLSearchParams(data)) {
1284
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
1285
return data.toString();
1286
}
1287
if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
1288
setContentTypeIfUnset(headers, 'application/json');
1289
return stringifySafely(data);
1290
}
1291
return data;
1292
}],
1293
1294
transformResponse: [function transformResponse(data) {
1295
var transitional = this.transitional || defaults.transitional;
1296
var silentJSONParsing = transitional && transitional.silentJSONParsing;
1297
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1298
var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
1299
1300
if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
1301
try {
1302
return JSON.parse(data);
1303
} catch (e) {
1304
if (strictJSONParsing) {
1305
if (e.name === 'SyntaxError') {
1306
throw enhanceError(e, this, 'E_JSON_PARSE');
1307
}
1308
throw e;
1309
}
1310
}
1311
}
1312
1313
return data;
1314
}],
1315
1316
/**
1317
* A timeout in milliseconds to abort a request. If set to 0 (default) a
1318
* timeout is not created.
1319
*/
1320
timeout: 0,
1321
1322
xsrfCookieName: 'XSRF-TOKEN',
1323
xsrfHeaderName: 'X-XSRF-TOKEN',
1324
1325
maxContentLength: -1,
1326
maxBodyLength: -1,
1327
1328
validateStatus: function validateStatus(status) {
1329
return status >= 200 && status < 300;
1330
},
1331
1332
headers: {
1333
common: {
1334
'Accept': 'application/json, text/plain, */*'
1335
}
1336
}
1337
};
1338
1339
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1340
defaults.headers[method] = {};
1341
});
1342
1343
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1344
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1345
});
1346
1347
module.exports = defaults;
1348
1349
1350
/***/ }),
1351
1352
/***/ "./lib/env/data.js":
1353
/*!*************************!*\
1354
!*** ./lib/env/data.js ***!
1355
\*************************/
1356
/*! no static exports found */
1357
/***/ (function(module, exports) {
1358
1359
module.exports = {
1360
"version": "0.24.0"
1361
};
1362
1363
/***/ }),
1364
1365
/***/ "./lib/helpers/bind.js":
1366
/*!*****************************!*\
1367
!*** ./lib/helpers/bind.js ***!
1368
\*****************************/
1369
/*! no static exports found */
1370
/***/ (function(module, exports, __webpack_require__) {
1371
1372
"use strict";
1373
1374
1375
module.exports = function bind(fn, thisArg) {
1376
return function wrap() {
1377
var args = new Array(arguments.length);
1378
for (var i = 0; i < args.length; i++) {
1379
args[i] = arguments[i];
1380
}
1381
return fn.apply(thisArg, args);
1382
};
1383
};
1384
1385
1386
/***/ }),
1387
1388
/***/ "./lib/helpers/buildURL.js":
1389
/*!*********************************!*\
1390
!*** ./lib/helpers/buildURL.js ***!
1391
\*********************************/
1392
/*! no static exports found */
1393
/***/ (function(module, exports, __webpack_require__) {
1394
1395
"use strict";
1396
1397
1398
var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
1399
1400
function encode(val) {
1401
return encodeURIComponent(val).
1402
replace(/%3A/gi, ':').
1403
replace(/%24/g, '$').
1404
replace(/%2C/gi, ',').
1405
replace(/%20/g, '+').
1406
replace(/%5B/gi, '[').
1407
replace(/%5D/gi, ']');
1408
}
1409
1410
/**
1411
* Build a URL by appending params to the end
1412
*
1413
* @param {string} url The base of the url (e.g., http://www.google.com)
1414
* @param {object} [params] The params to be appended
1415
* @returns {string} The formatted url
1416
*/
1417
module.exports = function buildURL(url, params, paramsSerializer) {
1418
/*eslint no-param-reassign:0*/
1419
if (!params) {
1420
return url;
1421
}
1422
1423
var serializedParams;
1424
if (paramsSerializer) {
1425
serializedParams = paramsSerializer(params);
1426
} else if (utils.isURLSearchParams(params)) {
1427
serializedParams = params.toString();
1428
} else {
1429
var parts = [];
1430
1431
utils.forEach(params, function serialize(val, key) {
1432
if (val === null || typeof val === 'undefined') {
1433
return;
1434
}
1435
1436
if (utils.isArray(val)) {
1437
key = key + '[]';
1438
} else {
1439
val = [val];
1440
}
1441
1442
utils.forEach(val, function parseValue(v) {
1443
if (utils.isDate(v)) {
1444
v = v.toISOString();
1445
} else if (utils.isObject(v)) {
1446
v = JSON.stringify(v);
1447
}
1448
parts.push(encode(key) + '=' + encode(v));
1449
});
1450
});
1451
1452
serializedParams = parts.join('&');
1453
}
1454
1455
if (serializedParams) {
1456
var hashmarkIndex = url.indexOf('#');
1457
if (hashmarkIndex !== -1) {
1458
url = url.slice(0, hashmarkIndex);
1459
}
1460
1461
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1462
}
1463
1464
return url;
1465
};
1466
1467
1468
/***/ }),
1469
1470
/***/ "./lib/helpers/combineURLs.js":
1471
/*!************************************!*\
1472
!*** ./lib/helpers/combineURLs.js ***!
1473
\************************************/
1474
/*! no static exports found */
1475
/***/ (function(module, exports, __webpack_require__) {
1476
1477
"use strict";
1478
1479
1480
/**
1481
* Creates a new URL by combining the specified URLs
1482
*
1483
* @param {string} baseURL The base URL
1484
* @param {string} relativeURL The relative URL
1485
* @returns {string} The combined URL
1486
*/
1487
module.exports = function combineURLs(baseURL, relativeURL) {
1488
return relativeURL
1489
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
1490
: baseURL;
1491
};
1492
1493
1494
/***/ }),
1495
1496
/***/ "./lib/helpers/cookies.js":
1497
/*!********************************!*\
1498
!*** ./lib/helpers/cookies.js ***!
1499
\********************************/
1500
/*! no static exports found */
1501
/***/ (function(module, exports, __webpack_require__) {
1502
1503
"use strict";
1504
1505
1506
var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
1507
1508
module.exports = (
1509
utils.isStandardBrowserEnv() ?
1510
1511
// Standard browser envs support document.cookie
1512
(function standardBrowserEnv() {
1513
return {
1514
write: function write(name, value, expires, path, domain, secure) {
1515
var cookie = [];
1516
cookie.push(name + '=' + encodeURIComponent(value));
1517
1518
if (utils.isNumber(expires)) {
1519
cookie.push('expires=' + new Date(expires).toGMTString());
1520
}
1521
1522
if (utils.isString(path)) {
1523
cookie.push('path=' + path);
1524
}
1525
1526
if (utils.isString(domain)) {
1527
cookie.push('domain=' + domain);
1528
}
1529
1530
if (secure === true) {
1531
cookie.push('secure');
1532
}
1533
1534
document.cookie = cookie.join('; ');
1535
},
1536
1537
read: function read(name) {
1538
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1539
return (match ? decodeURIComponent(match[3]) : null);
1540
},
1541
1542
remove: function remove(name) {
1543
this.write(name, '', Date.now() - 86400000);
1544
}
1545
};
1546
})() :
1547
1548
// Non standard browser env (web workers, react-native) lack needed support.
1549
(function nonStandardBrowserEnv() {
1550
return {
1551
write: function write() {},
1552
read: function read() { return null; },
1553
remove: function remove() {}
1554
};
1555
})()
1556
);
1557
1558
1559
/***/ }),
1560
1561
/***/ "./lib/helpers/isAbsoluteURL.js":
1562
/*!**************************************!*\
1563
!*** ./lib/helpers/isAbsoluteURL.js ***!
1564
\**************************************/
1565
/*! no static exports found */
1566
/***/ (function(module, exports, __webpack_require__) {
1567
1568
"use strict";
1569
1570
1571
/**
1572
* Determines whether the specified URL is absolute
1573
*
1574
* @param {string} url The URL to test
1575
* @returns {boolean} True if the specified URL is absolute, otherwise false
1576
*/
1577
module.exports = function isAbsoluteURL(url) {
1578
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1579
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1580
// by any combination of letters, digits, plus, period, or hyphen.
1581
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
1582
};
1583
1584
1585
/***/ }),
1586
1587
/***/ "./lib/helpers/isAxiosError.js":
1588
/*!*************************************!*\
1589
!*** ./lib/helpers/isAxiosError.js ***!
1590
\*************************************/
1591
/*! no static exports found */
1592
/***/ (function(module, exports, __webpack_require__) {
1593
1594
"use strict";
1595
1596
1597
/**
1598
* Determines whether the payload is an error thrown by Axios
1599
*
1600
* @param {*} payload The value to test
1601
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
1602
*/
1603
module.exports = function isAxiosError(payload) {
1604
return (typeof payload === 'object') && (payload.isAxiosError === true);
1605
};
1606
1607
1608
/***/ }),
1609
1610
/***/ "./lib/helpers/isURLSameOrigin.js":
1611
/*!****************************************!*\
1612
!*** ./lib/helpers/isURLSameOrigin.js ***!
1613
\****************************************/
1614
/*! no static exports found */
1615
/***/ (function(module, exports, __webpack_require__) {
1616
1617
"use strict";
1618
1619
1620
var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
1621
1622
module.exports = (
1623
utils.isStandardBrowserEnv() ?
1624
1625
// Standard browser envs have full support of the APIs needed to test
1626
// whether the request URL is of the same origin as current location.
1627
(function standardBrowserEnv() {
1628
var msie = /(msie|trident)/i.test(navigator.userAgent);
1629
var urlParsingNode = document.createElement('a');
1630
var originURL;
1631
1632
/**
1633
* Parse a URL to discover it's components
1634
*
1635
* @param {String} url The URL to be parsed
1636
* @returns {Object}
1637
*/
1638
function resolveURL(url) {
1639
var href = url;
1640
1641
if (msie) {
1642
// IE needs attribute set twice to normalize properties
1643
urlParsingNode.setAttribute('href', href);
1644
href = urlParsingNode.href;
1645
}
1646
1647
urlParsingNode.setAttribute('href', href);
1648
1649
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
1650
return {
1651
href: urlParsingNode.href,
1652
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
1653
host: urlParsingNode.host,
1654
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
1655
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
1656
hostname: urlParsingNode.hostname,
1657
port: urlParsingNode.port,
1658
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
1659
urlParsingNode.pathname :
1660
'/' + urlParsingNode.pathname
1661
};
1662
}
1663
1664
originURL = resolveURL(window.location.href);
1665
1666
/**
1667
* Determine if a URL shares the same origin as the current location
1668
*
1669
* @param {String} requestURL The URL to test
1670
* @returns {boolean} True if URL shares the same origin, otherwise false
1671
*/
1672
return function isURLSameOrigin(requestURL) {
1673
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
1674
return (parsed.protocol === originURL.protocol &&
1675
parsed.host === originURL.host);
1676
};
1677
})() :
1678
1679
// Non standard browser envs (web workers, react-native) lack needed support.
1680
(function nonStandardBrowserEnv() {
1681
return function isURLSameOrigin() {
1682
return true;
1683
};
1684
})()
1685
);
1686
1687
1688
/***/ }),
1689
1690
/***/ "./lib/helpers/normalizeHeaderName.js":
1691
/*!********************************************!*\
1692
!*** ./lib/helpers/normalizeHeaderName.js ***!
1693
\********************************************/
1694
/*! no static exports found */
1695
/***/ (function(module, exports, __webpack_require__) {
1696
1697
"use strict";
1698
1699
1700
var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
1701
1702
module.exports = function normalizeHeaderName(headers, normalizedName) {
1703
utils.forEach(headers, function processHeader(value, name) {
1704
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
1705
headers[normalizedName] = value;
1706
delete headers[name];
1707
}
1708
});
1709
};
1710
1711
1712
/***/ }),
1713
1714
/***/ "./lib/helpers/parseHeaders.js":
1715
/*!*************************************!*\
1716
!*** ./lib/helpers/parseHeaders.js ***!
1717
\*************************************/
1718
/*! no static exports found */
1719
/***/ (function(module, exports, __webpack_require__) {
1720
1721
"use strict";
1722
1723
1724
var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
1725
1726
// Headers whose duplicates are ignored by node
1727
// c.f. https://nodejs.org/api/http.html#http_message_headers
1728
var ignoreDuplicateOf = [
1729
'age', 'authorization', 'content-length', 'content-type', 'etag',
1730
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1731
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1732
'referer', 'retry-after', 'user-agent'
1733
];
1734
1735
/**
1736
* Parse headers into an object
1737
*
1738
* ```
1739
* Date: Wed, 27 Aug 2014 08:58:49 GMT
1740
* Content-Type: application/json
1741
* Connection: keep-alive
1742
* Transfer-Encoding: chunked
1743
* ```
1744
*
1745
* @param {String} headers Headers needing to be parsed
1746
* @returns {Object} Headers parsed into an object
1747
*/
1748
module.exports = function parseHeaders(headers) {
1749
var parsed = {};
1750
var key;
1751
var val;
1752
var i;
1753
1754
if (!headers) { return parsed; }
1755
1756
utils.forEach(headers.split('\n'), function parser(line) {
1757
i = line.indexOf(':');
1758
key = utils.trim(line.substr(0, i)).toLowerCase();
1759
val = utils.trim(line.substr(i + 1));
1760
1761
if (key) {
1762
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
1763
return;
1764
}
1765
if (key === 'set-cookie') {
1766
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
1767
} else {
1768
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1769
}
1770
}
1771
});
1772
1773
return parsed;
1774
};
1775
1776
1777
/***/ }),
1778
1779
/***/ "./lib/helpers/spread.js":
1780
/*!*******************************!*\
1781
!*** ./lib/helpers/spread.js ***!
1782
\*******************************/
1783
/*! no static exports found */
1784
/***/ (function(module, exports, __webpack_require__) {
1785
1786
"use strict";
1787
1788
1789
/**
1790
* Syntactic sugar for invoking a function and expanding an array for arguments.
1791
*
1792
* Common use case would be to use `Function.prototype.apply`.
1793
*
1794
* ```js
1795
* function f(x, y, z) {}
1796
* var args = [1, 2, 3];
1797
* f.apply(null, args);
1798
* ```
1799
*
1800
* With `spread` this example can be re-written.
1801
*
1802
* ```js
1803
* spread(function(x, y, z) {})([1, 2, 3]);
1804
* ```
1805
*
1806
* @param {Function} callback
1807
* @returns {Function}
1808
*/
1809
module.exports = function spread(callback) {
1810
return function wrap(arr) {
1811
return callback.apply(null, arr);
1812
};
1813
};
1814
1815
1816
/***/ }),
1817
1818
/***/ "./lib/helpers/validator.js":
1819
/*!**********************************!*\
1820
!*** ./lib/helpers/validator.js ***!
1821
\**********************************/
1822
/*! no static exports found */
1823
/***/ (function(module, exports, __webpack_require__) {
1824
1825
"use strict";
1826
1827
1828
var VERSION = __webpack_require__(/*! ../env/data */ "./lib/env/data.js").version;
1829
1830
var validators = {};
1831
1832
// eslint-disable-next-line func-names
1833
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
1834
validators[type] = function validator(thing) {
1835
return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
1836
};
1837
});
1838
1839
var deprecatedWarnings = {};
1840
1841
/**
1842
* Transitional option validator
1843
* @param {function|boolean?} validator - set to false if the transitional option has been removed
1844
* @param {string?} version - deprecated version / removed since version
1845
* @param {string?} message - some message with additional info
1846
* @returns {function}
1847
*/
1848
validators.transitional = function transitional(validator, version, message) {
1849
function formatMessage(opt, desc) {
1850
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
1851
}
1852
1853
// eslint-disable-next-line func-names
1854
return function(value, opt, opts) {
1855
if (validator === false) {
1856
throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
1857
}
1858
1859
if (version && !deprecatedWarnings[opt]) {
1860
deprecatedWarnings[opt] = true;
1861
// eslint-disable-next-line no-console
1862
console.warn(
1863
formatMessage(
1864
opt,
1865
' has been deprecated since v' + version + ' and will be removed in the near future'
1866
)
1867
);
1868
}
1869
1870
return validator ? validator(value, opt, opts) : true;
1871
};
1872
};
1873
1874
/**
1875
* Assert object's properties type
1876
* @param {object} options
1877
* @param {object} schema
1878
* @param {boolean?} allowUnknown
1879
*/
1880
1881
function assertOptions(options, schema, allowUnknown) {
1882
if (typeof options !== 'object') {
1883
throw new TypeError('options must be an object');
1884
}
1885
var keys = Object.keys(options);
1886
var i = keys.length;
1887
while (i-- > 0) {
1888
var opt = keys[i];
1889
var validator = schema[opt];
1890
if (validator) {
1891
var value = options[opt];
1892
var result = value === undefined || validator(value, opt, options);
1893
if (result !== true) {
1894
throw new TypeError('option ' + opt + ' must be ' + result);
1895
}
1896
continue;
1897
}
1898
if (allowUnknown !== true) {
1899
throw Error('Unknown option ' + opt);
1900
}
1901
}
1902
}
1903
1904
module.exports = {
1905
assertOptions: assertOptions,
1906
validators: validators
1907
};
1908
1909
1910
/***/ }),
1911
1912
/***/ "./lib/utils.js":
1913
/*!**********************!*\
1914
!*** ./lib/utils.js ***!
1915
\**********************/
1916
/*! no static exports found */
1917
/***/ (function(module, exports, __webpack_require__) {
1918
1919
"use strict";
1920
1921
1922
var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
1923
1924
// utils is a library of generic helper functions non-specific to axios
1925
1926
var toString = Object.prototype.toString;
1927
1928
/**
1929
* Determine if a value is an Array
1930
*
1931
* @param {Object} val The value to test
1932
* @returns {boolean} True if value is an Array, otherwise false
1933
*/
1934
function isArray(val) {
1935
return toString.call(val) === '[object Array]';
1936
}
1937
1938
/**
1939
* Determine if a value is undefined
1940
*
1941
* @param {Object} val The value to test
1942
* @returns {boolean} True if the value is undefined, otherwise false
1943
*/
1944
function isUndefined(val) {
1945
return typeof val === 'undefined';
1946
}
1947
1948
/**
1949
* Determine if a value is a Buffer
1950
*
1951
* @param {Object} val The value to test
1952
* @returns {boolean} True if value is a Buffer, otherwise false
1953
*/
1954
function isBuffer(val) {
1955
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
1956
&& typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
1957
}
1958
1959
/**
1960
* Determine if a value is an ArrayBuffer
1961
*
1962
* @param {Object} val The value to test
1963
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
1964
*/
1965
function isArrayBuffer(val) {
1966
return toString.call(val) === '[object ArrayBuffer]';
1967
}
1968
1969
/**
1970
* Determine if a value is a FormData
1971
*
1972
* @param {Object} val The value to test
1973
* @returns {boolean} True if value is an FormData, otherwise false
1974
*/
1975
function isFormData(val) {
1976
return (typeof FormData !== 'undefined') && (val instanceof FormData);
1977
}
1978
1979
/**
1980
* Determine if a value is a view on an ArrayBuffer
1981
*
1982
* @param {Object} val The value to test
1983
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
1984
*/
1985
function isArrayBufferView(val) {
1986
var result;
1987
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
1988
result = ArrayBuffer.isView(val);
1989
} else {
1990
result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
1991
}
1992
return result;
1993
}
1994
1995
/**
1996
* Determine if a value is a String
1997
*
1998
* @param {Object} val The value to test
1999
* @returns {boolean} True if value is a String, otherwise false
2000
*/
2001
function isString(val) {
2002
return typeof val === 'string';
2003
}
2004
2005
/**
2006
* Determine if a value is a Number
2007
*
2008
* @param {Object} val The value to test
2009
* @returns {boolean} True if value is a Number, otherwise false
2010
*/
2011
function isNumber(val) {
2012
return typeof val === 'number';
2013
}
2014
2015
/**
2016
* Determine if a value is an Object
2017
*
2018
* @param {Object} val The value to test
2019
* @returns {boolean} True if value is an Object, otherwise false
2020
*/
2021
function isObject(val) {
2022
return val !== null && typeof val === 'object';
2023
}
2024
2025
/**
2026
* Determine if a value is a plain Object
2027
*
2028
* @param {Object} val The value to test
2029
* @return {boolean} True if value is a plain Object, otherwise false
2030
*/
2031
function isPlainObject(val) {
2032
if (toString.call(val) !== '[object Object]') {
2033
return false;
2034
}
2035
2036
var prototype = Object.getPrototypeOf(val);
2037
return prototype === null || prototype === Object.prototype;
2038
}
2039
2040
/**
2041
* Determine if a value is a Date
2042
*
2043
* @param {Object} val The value to test
2044
* @returns {boolean} True if value is a Date, otherwise false
2045
*/
2046
function isDate(val) {
2047
return toString.call(val) === '[object Date]';
2048
}
2049
2050
/**
2051
* Determine if a value is a File
2052
*
2053
* @param {Object} val The value to test
2054
* @returns {boolean} True if value is a File, otherwise false
2055
*/
2056
function isFile(val) {
2057
return toString.call(val) === '[object File]';
2058
}
2059
2060
/**
2061
* Determine if a value is a Blob
2062
*
2063
* @param {Object} val The value to test
2064
* @returns {boolean} True if value is a Blob, otherwise false
2065
*/
2066
function isBlob(val) {
2067
return toString.call(val) === '[object Blob]';
2068
}
2069
2070
/**
2071
* Determine if a value is a Function
2072
*
2073
* @param {Object} val The value to test
2074
* @returns {boolean} True if value is a Function, otherwise false
2075
*/
2076
function isFunction(val) {
2077
return toString.call(val) === '[object Function]';
2078
}
2079
2080
/**
2081
* Determine if a value is a Stream
2082
*
2083
* @param {Object} val The value to test
2084
* @returns {boolean} True if value is a Stream, otherwise false
2085
*/
2086
function isStream(val) {
2087
return isObject(val) && isFunction(val.pipe);
2088
}
2089
2090
/**
2091
* Determine if a value is a URLSearchParams object
2092
*
2093
* @param {Object} val The value to test
2094
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
2095
*/
2096
function isURLSearchParams(val) {
2097
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
2098
}
2099
2100
/**
2101
* Trim excess whitespace off the beginning and end of a string
2102
*
2103
* @param {String} str The String to trim
2104
* @returns {String} The String freed of excess whitespace
2105
*/
2106
function trim(str) {
2107
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
2108
}
2109
2110
/**
2111
* Determine if we're running in a standard browser environment
2112
*
2113
* This allows axios to run in a web worker, and react-native.
2114
* Both environments support XMLHttpRequest, but not fully standard globals.
2115
*
2116
* web workers:
2117
* typeof window -> undefined
2118
* typeof document -> undefined
2119
*
2120
* react-native:
2121
* navigator.product -> 'ReactNative'
2122
* nativescript
2123
* navigator.product -> 'NativeScript' or 'NS'
2124
*/
2125
function isStandardBrowserEnv() {
2126
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
2127
navigator.product === 'NativeScript' ||
2128
navigator.product === 'NS')) {
2129
return false;
2130
}
2131
return (
2132
typeof window !== 'undefined' &&
2133
typeof document !== 'undefined'
2134
);
2135
}
2136
2137
/**
2138
* Iterate over an Array or an Object invoking a function for each item.
2139
*
2140
* If `obj` is an Array callback will be called passing
2141
* the value, index, and complete array for each item.
2142
*
2143
* If 'obj' is an Object callback will be called passing
2144
* the value, key, and complete object for each property.
2145
*
2146
* @param {Object|Array} obj The object to iterate
2147
* @param {Function} fn The callback to invoke for each item
2148
*/
2149
function forEach(obj, fn) {
2150
// Don't bother if no value provided
2151
if (obj === null || typeof obj === 'undefined') {
2152
return;
2153
}
2154
2155
// Force an array if not already something iterable
2156
if (typeof obj !== 'object') {
2157
/*eslint no-param-reassign:0*/
2158
obj = [obj];
2159
}
2160
2161
if (isArray(obj)) {
2162
// Iterate over array values
2163
for (var i = 0, l = obj.length; i < l; i++) {
2164
fn.call(null, obj[i], i, obj);
2165
}
2166
} else {
2167
// Iterate over object keys
2168
for (var key in obj) {
2169
if (Object.prototype.hasOwnProperty.call(obj, key)) {
2170
fn.call(null, obj[key], key, obj);
2171
}
2172
}
2173
}
2174
}
2175
2176
/**
2177
* Accepts varargs expecting each argument to be an object, then
2178
* immutably merges the properties of each object and returns result.
2179
*
2180
* When multiple objects contain the same key the later object in
2181
* the arguments list will take precedence.
2182
*
2183
* Example:
2184
*
2185
* ```js
2186
* var result = merge({foo: 123}, {foo: 456});
2187
* console.log(result.foo); // outputs 456
2188
* ```
2189
*
2190
* @param {Object} obj1 Object to merge
2191
* @returns {Object} Result of all merge properties
2192
*/
2193
function merge(/* obj1, obj2, obj3, ... */) {
2194
var result = {};
2195
function assignValue(val, key) {
2196
if (isPlainObject(result[key]) && isPlainObject(val)) {
2197
result[key] = merge(result[key], val);
2198
} else if (isPlainObject(val)) {
2199
result[key] = merge({}, val);
2200
} else if (isArray(val)) {
2201
result[key] = val.slice();
2202
} else {
2203
result[key] = val;
2204
}
2205
}
2206
2207
for (var i = 0, l = arguments.length; i < l; i++) {
2208
forEach(arguments[i], assignValue);
2209
}
2210
return result;
2211
}
2212
2213
/**
2214
* Extends object a by mutably adding to it the properties of object b.
2215
*
2216
* @param {Object} a The object to be extended
2217
* @param {Object} b The object to copy properties from
2218
* @param {Object} thisArg The object to bind function to
2219
* @return {Object} The resulting value of object a
2220
*/
2221
function extend(a, b, thisArg) {
2222
forEach(b, function assignValue(val, key) {
2223
if (thisArg && typeof val === 'function') {
2224
a[key] = bind(val, thisArg);
2225
} else {
2226
a[key] = val;
2227
}
2228
});
2229
return a;
2230
}
2231
2232
/**
2233
* Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
2234
*
2235
* @param {string} content with BOM
2236
* @return {string} content value without BOM
2237
*/
2238
function stripBOM(content) {
2239
if (content.charCodeAt(0) === 0xFEFF) {
2240
content = content.slice(1);
2241
}
2242
return content;
2243
}
2244
2245
module.exports = {
2246
isArray: isArray,
2247
isArrayBuffer: isArrayBuffer,
2248
isBuffer: isBuffer,
2249
isFormData: isFormData,
2250
isArrayBufferView: isArrayBufferView,
2251
isString: isString,
2252
isNumber: isNumber,
2253
isObject: isObject,
2254
isPlainObject: isPlainObject,
2255
isUndefined: isUndefined,
2256
isDate: isDate,
2257
isFile: isFile,
2258
isBlob: isBlob,
2259
isFunction: isFunction,
2260
isStream: isStream,
2261
isURLSearchParams: isURLSearchParams,
2262
isStandardBrowserEnv: isStandardBrowserEnv,
2263
forEach: forEach,
2264
merge: merge,
2265
extend: extend,
2266
trim: trim,
2267
stripBOM: stripBOM
2268
};
2269
2270
2271
/***/ })
2272
2273
/******/ });
2274
});
2275
//# sourceMappingURL=axios.map
2276