axios 0.26.1 → 0.27.2

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.
package/dist/axios.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* axios v0.27.2 | (c) 2022 by Matt Zabriskie */
1
2
  (function webpackUniversalModuleDefinition(root, factory) {
2
3
  if(typeof exports === 'object' && typeof module === 'object')
3
4
  module.exports = factory();
@@ -124,9 +125,10 @@ var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./lib/helpers/b
124
125
  var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./lib/core/buildFullPath.js");
125
126
  var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./lib/helpers/parseHeaders.js");
126
127
  var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./lib/helpers/isURLSameOrigin.js");
127
- var createError = __webpack_require__(/*! ../core/createError */ "./lib/core/createError.js");
128
128
  var transitionalDefaults = __webpack_require__(/*! ../defaults/transitional */ "./lib/defaults/transitional.js");
129
- var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./lib/cancel/Cancel.js");
129
+ var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
130
+ var CanceledError = __webpack_require__(/*! ../cancel/CanceledError */ "./lib/cancel/CanceledError.js");
131
+ var parseProtocol = __webpack_require__(/*! ../helpers/parseProtocol */ "./lib/helpers/parseProtocol.js");
130
132
 
131
133
  module.exports = function xhrAdapter(config) {
132
134
  return new Promise(function dispatchXhrRequest(resolve, reject) {
@@ -144,7 +146,7 @@ module.exports = function xhrAdapter(config) {
144
146
  }
145
147
  }
146
148
 
147
- if (utils.isFormData(requestData)) {
149
+ if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) {
148
150
  delete requestHeaders['Content-Type']; // Let the browser set it
149
151
  }
150
152
 
@@ -158,6 +160,7 @@ module.exports = function xhrAdapter(config) {
158
160
  }
159
161
 
160
162
  var fullPath = buildFullPath(config.baseURL, config.url);
163
+
161
164
  request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
162
165
 
163
166
  // Set the request timeout in MS
@@ -221,7 +224,7 @@ module.exports = function xhrAdapter(config) {
221
224
  return;
222
225
  }
223
226
 
224
- reject(createError('Request aborted', config, 'ECONNABORTED', request));
227
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
225
228
 
226
229
  // Clean up request
227
230
  request = null;
@@ -231,7 +234,7 @@ module.exports = function xhrAdapter(config) {
231
234
  request.onerror = function handleError() {
232
235
  // Real errors are hidden from us by the browser
233
236
  // onerror should only fire if it's a network error
234
- reject(createError('Network Error', config, null, request));
237
+ reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, request));
235
238
 
236
239
  // Clean up request
237
240
  request = null;
@@ -244,10 +247,10 @@ module.exports = function xhrAdapter(config) {
244
247
  if (config.timeoutErrorMessage) {
245
248
  timeoutErrorMessage = config.timeoutErrorMessage;
246
249
  }
247
- reject(createError(
250
+ reject(new AxiosError(
248
251
  timeoutErrorMessage,
252
+ transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
249
253
  config,
250
- transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
251
254
  request));
252
255
 
253
256
  // Clean up request
@@ -308,7 +311,7 @@ module.exports = function xhrAdapter(config) {
308
311
  if (!request) {
309
312
  return;
310
313
  }
311
- reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
314
+ reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel);
312
315
  request.abort();
313
316
  request = null;
314
317
  };
@@ -323,6 +326,14 @@ module.exports = function xhrAdapter(config) {
323
326
  requestData = null;
324
327
  }
325
328
 
329
+ var protocol = parseProtocol(fullPath);
330
+
331
+ if (protocol && [ 'http', 'https', 'file' ].indexOf(protocol) === -1) {
332
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
333
+ return;
334
+ }
335
+
336
+
326
337
  // Send the request
327
338
  request.send(requestData);
328
339
  });
@@ -378,10 +389,17 @@ var axios = createInstance(defaults);
378
389
  axios.Axios = Axios;
379
390
 
380
391
  // Expose Cancel & CancelToken
381
- axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./lib/cancel/Cancel.js");
392
+ axios.CanceledError = __webpack_require__(/*! ./cancel/CanceledError */ "./lib/cancel/CanceledError.js");
382
393
  axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./lib/cancel/CancelToken.js");
383
394
  axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./lib/cancel/isCancel.js");
384
395
  axios.VERSION = __webpack_require__(/*! ./env/data */ "./lib/env/data.js").version;
396
+ axios.toFormData = __webpack_require__(/*! ./helpers/toFormData */ "./lib/helpers/toFormData.js");
397
+
398
+ // Expose AxiosError class
399
+ axios.AxiosError = __webpack_require__(/*! ../lib/core/AxiosError */ "./lib/core/AxiosError.js");
400
+
401
+ // alias for CanceledError for backward compatibility
402
+ axios.Cancel = axios.CanceledError;
385
403
 
386
404
  // Expose all/spread
387
405
  axios.all = function all(promises) {
@@ -398,37 +416,6 @@ module.exports = axios;
398
416
  module.exports.default = axios;
399
417
 
400
418
 
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
419
  /***/ }),
433
420
 
434
421
  /***/ "./lib/cancel/CancelToken.js":
@@ -441,7 +428,7 @@ module.exports = Cancel;
441
428
  "use strict";
442
429
 
443
430
 
444
- var Cancel = __webpack_require__(/*! ./Cancel */ "./lib/cancel/Cancel.js");
431
+ var CanceledError = __webpack_require__(/*! ./CanceledError */ "./lib/cancel/CanceledError.js");
445
432
 
446
433
  /**
447
434
  * A `CancelToken` is an object that can be used to request cancellation of an operation.
@@ -497,13 +484,13 @@ function CancelToken(executor) {
497
484
  return;
498
485
  }
499
486
 
500
- token.reason = new Cancel(message);
487
+ token.reason = new CanceledError(message);
501
488
  resolvePromise(token.reason);
502
489
  });
503
490
  }
504
491
 
505
492
  /**
506
- * Throws a `Cancel` if cancellation has been requested.
493
+ * Throws a `CanceledError` if cancellation has been requested.
507
494
  */
508
495
  CancelToken.prototype.throwIfRequested = function throwIfRequested() {
509
496
  if (this.reason) {
@@ -560,6 +547,40 @@ CancelToken.source = function source() {
560
547
  module.exports = CancelToken;
561
548
 
562
549
 
550
+ /***/ }),
551
+
552
+ /***/ "./lib/cancel/CanceledError.js":
553
+ /*!*************************************!*\
554
+ !*** ./lib/cancel/CanceledError.js ***!
555
+ \*************************************/
556
+ /*! no static exports found */
557
+ /***/ (function(module, exports, __webpack_require__) {
558
+
559
+ "use strict";
560
+
561
+
562
+ var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
563
+ var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
564
+
565
+ /**
566
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
567
+ *
568
+ * @class
569
+ * @param {string=} message The message.
570
+ */
571
+ function CanceledError(message) {
572
+ // eslint-disable-next-line no-eq-null,eqeqeq
573
+ AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED);
574
+ this.name = 'CanceledError';
575
+ }
576
+
577
+ utils.inherits(CanceledError, AxiosError, {
578
+ __CANCEL__: true
579
+ });
580
+
581
+ module.exports = CanceledError;
582
+
583
+
563
584
  /***/ }),
564
585
 
565
586
  /***/ "./lib/cancel/isCancel.js":
@@ -594,6 +615,7 @@ var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./lib/helpers/bui
594
615
  var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./lib/core/InterceptorManager.js");
595
616
  var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./lib/core/dispatchRequest.js");
596
617
  var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./lib/core/mergeConfig.js");
618
+ var buildFullPath = __webpack_require__(/*! ./buildFullPath */ "./lib/core/buildFullPath.js");
597
619
  var validator = __webpack_require__(/*! ../helpers/validator */ "./lib/helpers/validator.js");
598
620
 
599
621
  var validators = validator.validators;
@@ -708,7 +730,8 @@ Axios.prototype.request = function request(configOrUrl, config) {
708
730
 
709
731
  Axios.prototype.getUri = function getUri(config) {
710
732
  config = mergeConfig(this.defaults, config);
711
- return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
733
+ var fullPath = buildFullPath(config.baseURL, config.url);
734
+ return buildURL(fullPath, config.params, config.paramsSerializer);
712
735
  };
713
736
 
714
737
  // Provide aliases for supported request methods
@@ -725,18 +748,126 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData
725
748
 
726
749
  utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
727
750
  /*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
- };
751
+
752
+ function generateHTTPMethod(isForm) {
753
+ return function httpMethod(url, data, config) {
754
+ return this.request(mergeConfig(config || {}, {
755
+ method: method,
756
+ headers: isForm ? {
757
+ 'Content-Type': 'multipart/form-data'
758
+ } : {},
759
+ url: url,
760
+ data: data
761
+ }));
762
+ };
763
+ }
764
+
765
+ Axios.prototype[method] = generateHTTPMethod();
766
+
767
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
735
768
  });
736
769
 
737
770
  module.exports = Axios;
738
771
 
739
772
 
773
+ /***/ }),
774
+
775
+ /***/ "./lib/core/AxiosError.js":
776
+ /*!********************************!*\
777
+ !*** ./lib/core/AxiosError.js ***!
778
+ \********************************/
779
+ /*! no static exports found */
780
+ /***/ (function(module, exports, __webpack_require__) {
781
+
782
+ "use strict";
783
+
784
+
785
+ var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
786
+
787
+ /**
788
+ * Create an Error with the specified message, config, error code, request and response.
789
+ *
790
+ * @param {string} message The error message.
791
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
792
+ * @param {Object} [config] The config.
793
+ * @param {Object} [request] The request.
794
+ * @param {Object} [response] The response.
795
+ * @returns {Error} The created error.
796
+ */
797
+ function AxiosError(message, code, config, request, response) {
798
+ Error.call(this);
799
+ this.message = message;
800
+ this.name = 'AxiosError';
801
+ code && (this.code = code);
802
+ config && (this.config = config);
803
+ request && (this.request = request);
804
+ response && (this.response = response);
805
+ }
806
+
807
+ utils.inherits(AxiosError, Error, {
808
+ toJSON: function toJSON() {
809
+ return {
810
+ // Standard
811
+ message: this.message,
812
+ name: this.name,
813
+ // Microsoft
814
+ description: this.description,
815
+ number: this.number,
816
+ // Mozilla
817
+ fileName: this.fileName,
818
+ lineNumber: this.lineNumber,
819
+ columnNumber: this.columnNumber,
820
+ stack: this.stack,
821
+ // Axios
822
+ config: this.config,
823
+ code: this.code,
824
+ status: this.response && this.response.status ? this.response.status : null
825
+ };
826
+ }
827
+ });
828
+
829
+ var prototype = AxiosError.prototype;
830
+ var descriptors = {};
831
+
832
+ [
833
+ 'ERR_BAD_OPTION_VALUE',
834
+ 'ERR_BAD_OPTION',
835
+ 'ECONNABORTED',
836
+ 'ETIMEDOUT',
837
+ 'ERR_NETWORK',
838
+ 'ERR_FR_TOO_MANY_REDIRECTS',
839
+ 'ERR_DEPRECATED',
840
+ 'ERR_BAD_RESPONSE',
841
+ 'ERR_BAD_REQUEST',
842
+ 'ERR_CANCELED'
843
+ // eslint-disable-next-line func-names
844
+ ].forEach(function(code) {
845
+ descriptors[code] = {value: code};
846
+ });
847
+
848
+ Object.defineProperties(AxiosError, descriptors);
849
+ Object.defineProperty(prototype, 'isAxiosError', {value: true});
850
+
851
+ // eslint-disable-next-line func-names
852
+ AxiosError.from = function(error, code, config, request, response, customProps) {
853
+ var axiosError = Object.create(prototype);
854
+
855
+ utils.toFlatObject(error, axiosError, function filter(obj) {
856
+ return obj !== Error.prototype;
857
+ });
858
+
859
+ AxiosError.call(axiosError, error.message, code, config, request, response);
860
+
861
+ axiosError.name = error.name;
862
+
863
+ customProps && Object.assign(axiosError, customProps);
864
+
865
+ return axiosError;
866
+ };
867
+
868
+ module.exports = AxiosError;
869
+
870
+
740
871
  /***/ }),
741
872
 
742
873
  /***/ "./lib/core/InterceptorManager.js":
@@ -835,36 +966,6 @@ module.exports = function buildFullPath(baseURL, requestedURL) {
835
966
  };
836
967
 
837
968
 
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
969
  /***/ }),
869
970
 
870
971
  /***/ "./lib/core/dispatchRequest.js":
@@ -881,10 +982,10 @@ var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
881
982
  var transformData = __webpack_require__(/*! ./transformData */ "./lib/core/transformData.js");
882
983
  var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./lib/cancel/isCancel.js");
883
984
  var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults/index.js");
884
- var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./lib/cancel/Cancel.js");
985
+ var CanceledError = __webpack_require__(/*! ../cancel/CanceledError */ "./lib/cancel/CanceledError.js");
885
986
 
886
987
  /**
887
- * Throws a `Cancel` if cancellation has been requested.
988
+ * Throws a `CanceledError` if cancellation has been requested.
888
989
  */
889
990
  function throwIfCancellationRequested(config) {
890
991
  if (config.cancelToken) {
@@ -892,7 +993,7 @@ function throwIfCancellationRequested(config) {
892
993
  }
893
994
 
894
995
  if (config.signal && config.signal.aborted) {
895
- throw new Cancel('canceled');
996
+ throw new CanceledError();
896
997
  }
897
998
  }
898
999
 
@@ -964,61 +1065,6 @@ module.exports = function dispatchRequest(config) {
964
1065
  };
965
1066
 
966
1067
 
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
1068
  /***/ }),
1023
1069
 
1024
1070
  /***/ "./lib/core/mergeConfig.js":
@@ -1111,6 +1157,7 @@ module.exports = function mergeConfig(config1, config2) {
1111
1157
  'decompress': defaultToConfig2,
1112
1158
  'maxContentLength': defaultToConfig2,
1113
1159
  'maxBodyLength': defaultToConfig2,
1160
+ 'beforeRedirect': defaultToConfig2,
1114
1161
  'transport': defaultToConfig2,
1115
1162
  'httpAgent': defaultToConfig2,
1116
1163
  'httpsAgent': defaultToConfig2,
@@ -1142,7 +1189,7 @@ module.exports = function mergeConfig(config1, config2) {
1142
1189
  "use strict";
1143
1190
 
1144
1191
 
1145
- var createError = __webpack_require__(/*! ./createError */ "./lib/core/createError.js");
1192
+ var AxiosError = __webpack_require__(/*! ./AxiosError */ "./lib/core/AxiosError.js");
1146
1193
 
1147
1194
  /**
1148
1195
  * Resolve or reject a Promise based on response status.
@@ -1156,10 +1203,10 @@ module.exports = function settle(resolve, reject, response) {
1156
1203
  if (!response.status || !validateStatus || validateStatus(response.status)) {
1157
1204
  resolve(response);
1158
1205
  } else {
1159
- reject(createError(
1206
+ reject(new AxiosError(
1160
1207
  'Request failed with status code ' + response.status,
1208
+ [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1161
1209
  response.config,
1162
- null,
1163
1210
  response.request,
1164
1211
  response
1165
1212
  ));
@@ -1215,8 +1262,9 @@ module.exports = function transformData(data, headers, fns) {
1215
1262
 
1216
1263
  var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
1217
1264
  var normalizeHeaderName = __webpack_require__(/*! ../helpers/normalizeHeaderName */ "./lib/helpers/normalizeHeaderName.js");
1218
- var enhanceError = __webpack_require__(/*! ../core/enhanceError */ "./lib/core/enhanceError.js");
1265
+ var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
1219
1266
  var transitionalDefaults = __webpack_require__(/*! ./transitional */ "./lib/defaults/transitional.js");
1267
+ var toFormData = __webpack_require__(/*! ../helpers/toFormData */ "./lib/helpers/toFormData.js");
1220
1268
 
1221
1269
  var DEFAULT_CONTENT_TYPE = {
1222
1270
  'Content-Type': 'application/x-www-form-urlencoded'
@@ -1281,10 +1329,20 @@ var defaults = {
1281
1329
  setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
1282
1330
  return data.toString();
1283
1331
  }
1284
- if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
1332
+
1333
+ var isObjectPayload = utils.isObject(data);
1334
+ var contentType = headers && headers['Content-Type'];
1335
+
1336
+ var isFileList;
1337
+
1338
+ if ((isFileList = utils.isFileList(data)) || (isObjectPayload && contentType === 'multipart/form-data')) {
1339
+ var _FormData = this.env && this.env.FormData;
1340
+ return toFormData(isFileList ? {'files[]': data} : data, _FormData && new _FormData());
1341
+ } else if (isObjectPayload || contentType === 'application/json') {
1285
1342
  setContentTypeIfUnset(headers, 'application/json');
1286
1343
  return stringifySafely(data);
1287
1344
  }
1345
+
1288
1346
  return data;
1289
1347
  }],
1290
1348
 
@@ -1300,7 +1358,7 @@ var defaults = {
1300
1358
  } catch (e) {
1301
1359
  if (strictJSONParsing) {
1302
1360
  if (e.name === 'SyntaxError') {
1303
- throw enhanceError(e, this, 'E_JSON_PARSE');
1361
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1304
1362
  }
1305
1363
  throw e;
1306
1364
  }
@@ -1322,6 +1380,10 @@ var defaults = {
1322
1380
  maxContentLength: -1,
1323
1381
  maxBodyLength: -1,
1324
1382
 
1383
+ env: {
1384
+ FormData: __webpack_require__(/*! ./env/FormData */ "./lib/helpers/null.js")
1385
+ },
1386
+
1325
1387
  validateStatus: function validateStatus(status) {
1326
1388
  return status >= 200 && status < 300;
1327
1389
  },
@@ -1373,7 +1435,7 @@ module.exports = {
1373
1435
  /***/ (function(module, exports) {
1374
1436
 
1375
1437
  module.exports = {
1376
- "version": "0.26.1"
1438
+ "version": "0.27.2"
1377
1439
  };
1378
1440
 
1379
1441
  /***/ }),
@@ -1727,6 +1789,19 @@ module.exports = function normalizeHeaderName(headers, normalizedName) {
1727
1789
  };
1728
1790
 
1729
1791
 
1792
+ /***/ }),
1793
+
1794
+ /***/ "./lib/helpers/null.js":
1795
+ /*!*****************************!*\
1796
+ !*** ./lib/helpers/null.js ***!
1797
+ \*****************************/
1798
+ /*! no static exports found */
1799
+ /***/ (function(module, exports) {
1800
+
1801
+ // eslint-disable-next-line strict
1802
+ module.exports = null;
1803
+
1804
+
1730
1805
  /***/ }),
1731
1806
 
1732
1807
  /***/ "./lib/helpers/parseHeaders.js":
@@ -1792,6 +1867,24 @@ module.exports = function parseHeaders(headers) {
1792
1867
  };
1793
1868
 
1794
1869
 
1870
+ /***/ }),
1871
+
1872
+ /***/ "./lib/helpers/parseProtocol.js":
1873
+ /*!**************************************!*\
1874
+ !*** ./lib/helpers/parseProtocol.js ***!
1875
+ \**************************************/
1876
+ /*! no static exports found */
1877
+ /***/ (function(module, exports, __webpack_require__) {
1878
+
1879
+ "use strict";
1880
+
1881
+
1882
+ module.exports = function parseProtocol(url) {
1883
+ var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1884
+ return match && match[1] || '';
1885
+ };
1886
+
1887
+
1795
1888
  /***/ }),
1796
1889
 
1797
1890
  /***/ "./lib/helpers/spread.js":
@@ -1831,6 +1924,90 @@ module.exports = function spread(callback) {
1831
1924
  };
1832
1925
 
1833
1926
 
1927
+ /***/ }),
1928
+
1929
+ /***/ "./lib/helpers/toFormData.js":
1930
+ /*!***********************************!*\
1931
+ !*** ./lib/helpers/toFormData.js ***!
1932
+ \***********************************/
1933
+ /*! no static exports found */
1934
+ /***/ (function(module, exports, __webpack_require__) {
1935
+
1936
+ "use strict";
1937
+
1938
+
1939
+ var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
1940
+
1941
+ /**
1942
+ * Convert a data object to FormData
1943
+ * @param {Object} obj
1944
+ * @param {?Object} [formData]
1945
+ * @returns {Object}
1946
+ **/
1947
+
1948
+ function toFormData(obj, formData) {
1949
+ // eslint-disable-next-line no-param-reassign
1950
+ formData = formData || new FormData();
1951
+
1952
+ var stack = [];
1953
+
1954
+ function convertValue(value) {
1955
+ if (value === null) return '';
1956
+
1957
+ if (utils.isDate(value)) {
1958
+ return value.toISOString();
1959
+ }
1960
+
1961
+ if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
1962
+ return typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1963
+ }
1964
+
1965
+ return value;
1966
+ }
1967
+
1968
+ function build(data, parentKey) {
1969
+ if (utils.isPlainObject(data) || utils.isArray(data)) {
1970
+ if (stack.indexOf(data) !== -1) {
1971
+ throw Error('Circular reference detected in ' + parentKey);
1972
+ }
1973
+
1974
+ stack.push(data);
1975
+
1976
+ utils.forEach(data, function each(value, key) {
1977
+ if (utils.isUndefined(value)) return;
1978
+ var fullKey = parentKey ? parentKey + '.' + key : key;
1979
+ var arr;
1980
+
1981
+ if (value && !parentKey && typeof value === 'object') {
1982
+ if (utils.endsWith(key, '{}')) {
1983
+ // eslint-disable-next-line no-param-reassign
1984
+ value = JSON.stringify(value);
1985
+ } else if (utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
1986
+ // eslint-disable-next-line func-names
1987
+ arr.forEach(function(el) {
1988
+ !utils.isUndefined(el) && formData.append(fullKey, convertValue(el));
1989
+ });
1990
+ return;
1991
+ }
1992
+ }
1993
+
1994
+ build(value, fullKey);
1995
+ });
1996
+
1997
+ stack.pop();
1998
+ } else {
1999
+ formData.append(parentKey, convertValue(data));
2000
+ }
2001
+ }
2002
+
2003
+ build(obj);
2004
+
2005
+ return formData;
2006
+ }
2007
+
2008
+ module.exports = toFormData;
2009
+
2010
+
1834
2011
  /***/ }),
1835
2012
 
1836
2013
  /***/ "./lib/helpers/validator.js":
@@ -1844,6 +2021,7 @@ module.exports = function spread(callback) {
1844
2021
 
1845
2022
 
1846
2023
  var VERSION = __webpack_require__(/*! ../env/data */ "./lib/env/data.js").version;
2024
+ var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
1847
2025
 
1848
2026
  var validators = {};
1849
2027
 
@@ -1871,7 +2049,10 @@ validators.transitional = function transitional(validator, version, message) {
1871
2049
  // eslint-disable-next-line func-names
1872
2050
  return function(value, opt, opts) {
1873
2051
  if (validator === false) {
1874
- throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
2052
+ throw new AxiosError(
2053
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
2054
+ AxiosError.ERR_DEPRECATED
2055
+ );
1875
2056
  }
1876
2057
 
1877
2058
  if (version && !deprecatedWarnings[opt]) {
@@ -1898,7 +2079,7 @@ validators.transitional = function transitional(validator, version, message) {
1898
2079
 
1899
2080
  function assertOptions(options, schema, allowUnknown) {
1900
2081
  if (typeof options !== 'object') {
1901
- throw new TypeError('options must be an object');
2082
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
1902
2083
  }
1903
2084
  var keys = Object.keys(options);
1904
2085
  var i = keys.length;
@@ -1909,12 +2090,12 @@ function assertOptions(options, schema, allowUnknown) {
1909
2090
  var value = options[opt];
1910
2091
  var result = value === undefined || validator(value, opt, options);
1911
2092
  if (result !== true) {
1912
- throw new TypeError('option ' + opt + ' must be ' + result);
2093
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
1913
2094
  }
1914
2095
  continue;
1915
2096
  }
1916
2097
  if (allowUnknown !== true) {
1917
- throw Error('Unknown option ' + opt);
2098
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
1918
2099
  }
1919
2100
  }
1920
2101
  }
@@ -1943,6 +2124,22 @@ var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
1943
2124
 
1944
2125
  var toString = Object.prototype.toString;
1945
2126
 
2127
+ // eslint-disable-next-line func-names
2128
+ var kindOf = (function(cache) {
2129
+ // eslint-disable-next-line func-names
2130
+ return function(thing) {
2131
+ var str = toString.call(thing);
2132
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
2133
+ };
2134
+ })(Object.create(null));
2135
+
2136
+ function kindOfTest(type) {
2137
+ type = type.toLowerCase();
2138
+ return function isKindOf(thing) {
2139
+ return kindOf(thing) === type;
2140
+ };
2141
+ }
2142
+
1946
2143
  /**
1947
2144
  * Determine if a value is an Array
1948
2145
  *
@@ -1977,22 +2174,12 @@ function isBuffer(val) {
1977
2174
  /**
1978
2175
  * Determine if a value is an ArrayBuffer
1979
2176
  *
2177
+ * @function
1980
2178
  * @param {Object} val The value to test
1981
2179
  * @returns {boolean} True if value is an ArrayBuffer, otherwise false
1982
2180
  */
1983
- function isArrayBuffer(val) {
1984
- return toString.call(val) === '[object ArrayBuffer]';
1985
- }
2181
+ var isArrayBuffer = kindOfTest('ArrayBuffer');
1986
2182
 
1987
- /**
1988
- * Determine if a value is a FormData
1989
- *
1990
- * @param {Object} val The value to test
1991
- * @returns {boolean} True if value is an FormData, otherwise false
1992
- */
1993
- function isFormData(val) {
1994
- return toString.call(val) === '[object FormData]';
1995
- }
1996
2183
 
1997
2184
  /**
1998
2185
  * Determine if a value is a view on an ArrayBuffer
@@ -2047,7 +2234,7 @@ function isObject(val) {
2047
2234
  * @return {boolean} True if value is a plain Object, otherwise false
2048
2235
  */
2049
2236
  function isPlainObject(val) {
2050
- if (toString.call(val) !== '[object Object]') {
2237
+ if (kindOf(val) !== 'object') {
2051
2238
  return false;
2052
2239
  }
2053
2240
 
@@ -2058,32 +2245,38 @@ function isPlainObject(val) {
2058
2245
  /**
2059
2246
  * Determine if a value is a Date
2060
2247
  *
2248
+ * @function
2061
2249
  * @param {Object} val The value to test
2062
2250
  * @returns {boolean} True if value is a Date, otherwise false
2063
2251
  */
2064
- function isDate(val) {
2065
- return toString.call(val) === '[object Date]';
2066
- }
2252
+ var isDate = kindOfTest('Date');
2067
2253
 
2068
2254
  /**
2069
2255
  * Determine if a value is a File
2070
2256
  *
2257
+ * @function
2071
2258
  * @param {Object} val The value to test
2072
2259
  * @returns {boolean} True if value is a File, otherwise false
2073
2260
  */
2074
- function isFile(val) {
2075
- return toString.call(val) === '[object File]';
2076
- }
2261
+ var isFile = kindOfTest('File');
2077
2262
 
2078
2263
  /**
2079
2264
  * Determine if a value is a Blob
2080
2265
  *
2266
+ * @function
2081
2267
  * @param {Object} val The value to test
2082
2268
  * @returns {boolean} True if value is a Blob, otherwise false
2083
2269
  */
2084
- function isBlob(val) {
2085
- return toString.call(val) === '[object Blob]';
2086
- }
2270
+ var isBlob = kindOfTest('Blob');
2271
+
2272
+ /**
2273
+ * Determine if a value is a FileList
2274
+ *
2275
+ * @function
2276
+ * @param {Object} val The value to test
2277
+ * @returns {boolean} True if value is a File, otherwise false
2278
+ */
2279
+ var isFileList = kindOfTest('FileList');
2087
2280
 
2088
2281
  /**
2089
2282
  * Determine if a value is a Function
@@ -2106,14 +2299,27 @@ function isStream(val) {
2106
2299
  }
2107
2300
 
2108
2301
  /**
2109
- * Determine if a value is a URLSearchParams object
2302
+ * Determine if a value is a FormData
2110
2303
  *
2304
+ * @param {Object} thing The value to test
2305
+ * @returns {boolean} True if value is an FormData, otherwise false
2306
+ */
2307
+ function isFormData(thing) {
2308
+ var pattern = '[object FormData]';
2309
+ return thing && (
2310
+ (typeof FormData === 'function' && thing instanceof FormData) ||
2311
+ toString.call(thing) === pattern ||
2312
+ (isFunction(thing.toString) && thing.toString() === pattern)
2313
+ );
2314
+ }
2315
+
2316
+ /**
2317
+ * Determine if a value is a URLSearchParams object
2318
+ * @function
2111
2319
  * @param {Object} val The value to test
2112
2320
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
2113
2321
  */
2114
- function isURLSearchParams(val) {
2115
- return toString.call(val) === '[object URLSearchParams]';
2116
- }
2322
+ var isURLSearchParams = kindOfTest('URLSearchParams');
2117
2323
 
2118
2324
  /**
2119
2325
  * Trim excess whitespace off the beginning and end of a string
@@ -2260,6 +2466,94 @@ function stripBOM(content) {
2260
2466
  return content;
2261
2467
  }
2262
2468
 
2469
+ /**
2470
+ * Inherit the prototype methods from one constructor into another
2471
+ * @param {function} constructor
2472
+ * @param {function} superConstructor
2473
+ * @param {object} [props]
2474
+ * @param {object} [descriptors]
2475
+ */
2476
+
2477
+ function inherits(constructor, superConstructor, props, descriptors) {
2478
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
2479
+ constructor.prototype.constructor = constructor;
2480
+ props && Object.assign(constructor.prototype, props);
2481
+ }
2482
+
2483
+ /**
2484
+ * Resolve object with deep prototype chain to a flat object
2485
+ * @param {Object} sourceObj source object
2486
+ * @param {Object} [destObj]
2487
+ * @param {Function} [filter]
2488
+ * @returns {Object}
2489
+ */
2490
+
2491
+ function toFlatObject(sourceObj, destObj, filter) {
2492
+ var props;
2493
+ var i;
2494
+ var prop;
2495
+ var merged = {};
2496
+
2497
+ destObj = destObj || {};
2498
+
2499
+ do {
2500
+ props = Object.getOwnPropertyNames(sourceObj);
2501
+ i = props.length;
2502
+ while (i-- > 0) {
2503
+ prop = props[i];
2504
+ if (!merged[prop]) {
2505
+ destObj[prop] = sourceObj[prop];
2506
+ merged[prop] = true;
2507
+ }
2508
+ }
2509
+ sourceObj = Object.getPrototypeOf(sourceObj);
2510
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
2511
+
2512
+ return destObj;
2513
+ }
2514
+
2515
+ /*
2516
+ * determines whether a string ends with the characters of a specified string
2517
+ * @param {String} str
2518
+ * @param {String} searchString
2519
+ * @param {Number} [position= 0]
2520
+ * @returns {boolean}
2521
+ */
2522
+ function endsWith(str, searchString, position) {
2523
+ str = String(str);
2524
+ if (position === undefined || position > str.length) {
2525
+ position = str.length;
2526
+ }
2527
+ position -= searchString.length;
2528
+ var lastIndex = str.indexOf(searchString, position);
2529
+ return lastIndex !== -1 && lastIndex === position;
2530
+ }
2531
+
2532
+
2533
+ /**
2534
+ * Returns new array from array like object
2535
+ * @param {*} [thing]
2536
+ * @returns {Array}
2537
+ */
2538
+ function toArray(thing) {
2539
+ if (!thing) return null;
2540
+ var i = thing.length;
2541
+ if (isUndefined(i)) return null;
2542
+ var arr = new Array(i);
2543
+ while (i-- > 0) {
2544
+ arr[i] = thing[i];
2545
+ }
2546
+ return arr;
2547
+ }
2548
+
2549
+ // eslint-disable-next-line func-names
2550
+ var isTypedArray = (function(TypedArray) {
2551
+ // eslint-disable-next-line func-names
2552
+ return function(thing) {
2553
+ return TypedArray && thing instanceof TypedArray;
2554
+ };
2555
+ })(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
2556
+
2263
2557
  module.exports = {
2264
2558
  isArray: isArray,
2265
2559
  isArrayBuffer: isArrayBuffer,
@@ -2282,7 +2576,15 @@ module.exports = {
2282
2576
  merge: merge,
2283
2577
  extend: extend,
2284
2578
  trim: trim,
2285
- stripBOM: stripBOM
2579
+ stripBOM: stripBOM,
2580
+ inherits: inherits,
2581
+ toFlatObject: toFlatObject,
2582
+ kindOf: kindOf,
2583
+ kindOfTest: kindOfTest,
2584
+ endsWith: endsWith,
2585
+ toArray: toArray,
2586
+ isTypedArray: isTypedArray,
2587
+ isFileList: isFileList
2286
2588
  };
2287
2589
 
2288
2590