axios 1.13.1 → 1.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! Axios v1.13.1 Copyright (c) 2025 Matt Zabriskie and contributors */
1
+ /*! Axios v1.13.3 Copyright (c) 2026 Matt Zabriskie and contributors */
2
2
  'use strict';
3
3
 
4
4
  /**
@@ -264,10 +264,11 @@ const trim = (str) => str.trim ?
264
264
  * If 'obj' is an Object callback will be called passing
265
265
  * the value, key, and complete object for each property.
266
266
  *
267
- * @param {Object|Array} obj The object to iterate
267
+ * @param {Object|Array<unknown>} obj The object to iterate
268
268
  * @param {Function} fn The callback to invoke for each item
269
269
  *
270
- * @param {Boolean} [allOwnKeys = false]
270
+ * @param {Object} [options]
271
+ * @param {Boolean} [options.allOwnKeys = false]
271
272
  * @returns {any}
272
273
  */
273
274
  function forEach(obj, fn, {allOwnKeys = false} = {}) {
@@ -344,7 +345,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
344
345
  * Example:
345
346
  *
346
347
  * ```js
347
- * var result = merge({foo: 123}, {foo: 456});
348
+ * const result = merge({foo: 123}, {foo: 456});
348
349
  * console.log(result.foo); // outputs 456
349
350
  * ```
350
351
  *
@@ -381,15 +382,26 @@ function merge(/* obj1, obj2, obj3, ... */) {
381
382
  * @param {Object} b The object to copy properties from
382
383
  * @param {Object} thisArg The object to bind function to
383
384
  *
384
- * @param {Boolean} [allOwnKeys]
385
+ * @param {Object} [options]
386
+ * @param {Boolean} [options.allOwnKeys]
385
387
  * @returns {Object} The resulting value of object a
386
388
  */
387
389
  const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
388
390
  forEach(b, (val, key) => {
389
391
  if (thisArg && isFunction$1(val)) {
390
- a[key] = bind(val, thisArg);
392
+ Object.defineProperty(a, key, {
393
+ value: bind(val, thisArg),
394
+ writable: true,
395
+ enumerable: true,
396
+ configurable: true
397
+ });
391
398
  } else {
392
- a[key] = val;
399
+ Object.defineProperty(a, key, {
400
+ value: val,
401
+ writable: true,
402
+ enumerable: true,
403
+ configurable: true
404
+ });
393
405
  }
394
406
  }, {allOwnKeys});
395
407
  return a;
@@ -420,7 +432,12 @@ const stripBOM = (content) => {
420
432
  */
421
433
  const inherits = (constructor, superConstructor, props, descriptors) => {
422
434
  constructor.prototype = Object.create(superConstructor.prototype, descriptors);
423
- constructor.prototype.constructor = constructor;
435
+ Object.defineProperty(constructor.prototype, 'constructor', {
436
+ value: constructor,
437
+ writable: true,
438
+ enumerable: false,
439
+ configurable: true
440
+ });
424
441
  Object.defineProperty(constructor, 'super', {
425
442
  value: superConstructor.prototype
426
443
  });
@@ -793,110 +810,75 @@ var utils$1 = {
793
810
  isIterable
794
811
  };
795
812
 
796
- /**
797
- * Create an Error with the specified message, config, error code, request and response.
798
- *
799
- * @param {string} message The error message.
800
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
801
- * @param {Object} [config] The config.
802
- * @param {Object} [request] The request.
803
- * @param {Object} [response] The response.
804
- *
805
- * @returns {Error} The created error.
806
- */
807
- function AxiosError(message, code, config, request, response) {
808
- Error.call(this);
809
-
810
- if (Error.captureStackTrace) {
811
- Error.captureStackTrace(this, this.constructor);
812
- } else {
813
- this.stack = (new Error()).stack;
814
- }
813
+ class AxiosError extends Error {
814
+ static from(error, code, config, request, response, customProps) {
815
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
816
+ axiosError.cause = error;
817
+ axiosError.name = error.name;
818
+ customProps && Object.assign(axiosError, customProps);
819
+ return axiosError;
820
+ }
821
+
822
+ /**
823
+ * Create an Error with the specified message, config, error code, request and response.
824
+ *
825
+ * @param {string} message The error message.
826
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
827
+ * @param {Object} [config] The config.
828
+ * @param {Object} [request] The request.
829
+ * @param {Object} [response] The response.
830
+ *
831
+ * @returns {Error} The created error.
832
+ */
833
+ constructor(message, code, config, request, response) {
834
+ super(message);
835
+ this.name = 'AxiosError';
836
+ this.isAxiosError = true;
837
+ code && (this.code = code);
838
+ config && (this.config = config);
839
+ request && (this.request = request);
840
+ if (response) {
841
+ this.response = response;
842
+ this.status = response.status;
843
+ }
844
+ }
815
845
 
816
- this.message = message;
817
- this.name = 'AxiosError';
818
- code && (this.code = code);
819
- config && (this.config = config);
820
- request && (this.request = request);
821
- if (response) {
822
- this.response = response;
823
- this.status = response.status ? response.status : null;
824
- }
846
+ toJSON() {
847
+ return {
848
+ // Standard
849
+ message: this.message,
850
+ name: this.name,
851
+ // Microsoft
852
+ description: this.description,
853
+ number: this.number,
854
+ // Mozilla
855
+ fileName: this.fileName,
856
+ lineNumber: this.lineNumber,
857
+ columnNumber: this.columnNumber,
858
+ stack: this.stack,
859
+ // Axios
860
+ config: utils$1.toJSONObject(this.config),
861
+ code: this.code,
862
+ status: this.status,
863
+ };
864
+ }
825
865
  }
826
866
 
827
- utils$1.inherits(AxiosError, Error, {
828
- toJSON: function toJSON() {
829
- return {
830
- // Standard
831
- message: this.message,
832
- name: this.name,
833
- // Microsoft
834
- description: this.description,
835
- number: this.number,
836
- // Mozilla
837
- fileName: this.fileName,
838
- lineNumber: this.lineNumber,
839
- columnNumber: this.columnNumber,
840
- stack: this.stack,
841
- // Axios
842
- config: utils$1.toJSONObject(this.config),
843
- code: this.code,
844
- status: this.status
845
- };
846
- }
847
- });
848
-
849
- const prototype$1 = AxiosError.prototype;
850
- const descriptors = {};
851
-
852
- [
853
- 'ERR_BAD_OPTION_VALUE',
854
- 'ERR_BAD_OPTION',
855
- 'ECONNABORTED',
856
- 'ETIMEDOUT',
857
- 'ERR_NETWORK',
858
- 'ERR_FR_TOO_MANY_REDIRECTS',
859
- 'ERR_DEPRECATED',
860
- 'ERR_BAD_RESPONSE',
861
- 'ERR_BAD_REQUEST',
862
- 'ERR_CANCELED',
863
- 'ERR_NOT_SUPPORT',
864
- 'ERR_INVALID_URL'
865
- // eslint-disable-next-line func-names
866
- ].forEach(code => {
867
- descriptors[code] = {value: code};
868
- });
869
-
870
- Object.defineProperties(AxiosError, descriptors);
871
- Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
872
-
873
- // eslint-disable-next-line func-names
874
- AxiosError.from = (error, code, config, request, response, customProps) => {
875
- const axiosError = Object.create(prototype$1);
876
-
877
- utils$1.toFlatObject(error, axiosError, function filter(obj) {
878
- return obj !== Error.prototype;
879
- }, prop => {
880
- return prop !== 'isAxiosError';
881
- });
882
-
883
- const msg = error && error.message ? error.message : 'Error';
884
-
885
- // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
886
- const errCode = code == null && error ? error.code : code;
887
- AxiosError.call(axiosError, msg, errCode, config, request, response);
888
-
889
- // Chain the original error on the standard field; non-enumerable to avoid JSON noise
890
- if (error && axiosError.cause == null) {
891
- Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
892
- }
893
-
894
- axiosError.name = (error && error.name) || 'Error';
895
-
896
- customProps && Object.assign(axiosError, customProps);
897
-
898
- return axiosError;
899
- };
867
+ // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
868
+ AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
869
+ AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
870
+ AxiosError.ECONNABORTED = 'ECONNABORTED';
871
+ AxiosError.ETIMEDOUT = 'ETIMEDOUT';
872
+ AxiosError.ERR_NETWORK = 'ERR_NETWORK';
873
+ AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
874
+ AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
875
+ AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
876
+ AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
877
+ AxiosError.ERR_CANCELED = 'ERR_CANCELED';
878
+ AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
879
+ AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
880
+
881
+ var AxiosError$1 = AxiosError;
900
882
 
901
883
  // eslint-disable-next-line strict
902
884
  var httpAdapter = null;
@@ -1021,7 +1003,7 @@ function toFormData(obj, formData, options) {
1021
1003
  }
1022
1004
 
1023
1005
  if (!useBlob && utils$1.isBlob(value)) {
1024
- throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1006
+ throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
1025
1007
  }
1026
1008
 
1027
1009
  if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
@@ -1195,29 +1177,26 @@ function encode(val) {
1195
1177
  * @returns {string} The formatted url
1196
1178
  */
1197
1179
  function buildURL(url, params, options) {
1198
- /*eslint no-param-reassign:0*/
1199
1180
  if (!params) {
1200
1181
  return url;
1201
1182
  }
1202
-
1183
+
1203
1184
  const _encode = options && options.encode || encode;
1204
1185
 
1205
- if (utils$1.isFunction(options)) {
1206
- options = {
1207
- serialize: options
1208
- };
1209
- }
1186
+ const _options = utils$1.isFunction(options) ? {
1187
+ serialize: options
1188
+ } : options;
1210
1189
 
1211
- const serializeFn = options && options.serialize;
1190
+ const serializeFn = _options && _options.serialize;
1212
1191
 
1213
1192
  let serializedParams;
1214
1193
 
1215
1194
  if (serializeFn) {
1216
- serializedParams = serializeFn(params, options);
1195
+ serializedParams = serializeFn(params, _options);
1217
1196
  } else {
1218
1197
  serializedParams = utils$1.isURLSearchParams(params) ?
1219
1198
  params.toString() :
1220
- new AxiosURLSearchParams(params, options).toString(_encode);
1199
+ new AxiosURLSearchParams(params, _options).toString(_encode);
1221
1200
  }
1222
1201
 
1223
1202
  if (serializedParams) {
@@ -1242,6 +1221,7 @@ class InterceptorManager {
1242
1221
  *
1243
1222
  * @param {Function} fulfilled The function to handle `then` for a `Promise`
1244
1223
  * @param {Function} rejected The function to handle `reject` for a `Promise`
1224
+ * @param {Object} options The options for the interceptor, synchronous and runWhen
1245
1225
  *
1246
1226
  * @return {Number} An ID used to remove interceptor later
1247
1227
  */
@@ -1591,7 +1571,7 @@ const defaults = {
1591
1571
  } catch (e) {
1592
1572
  if (strictJSONParsing) {
1593
1573
  if (e.name === 'SyntaxError') {
1594
- throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1574
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1595
1575
  }
1596
1576
  throw e;
1597
1577
  }
@@ -2025,24 +2005,24 @@ function isCancel(value) {
2025
2005
  return !!(value && value.__CANCEL__);
2026
2006
  }
2027
2007
 
2028
- /**
2029
- * A `CanceledError` is an object that is thrown when an operation is canceled.
2030
- *
2031
- * @param {string=} message The message.
2032
- * @param {Object=} config The config.
2033
- * @param {Object=} request The request.
2034
- *
2035
- * @returns {CanceledError} The created error.
2036
- */
2037
- function CanceledError(message, config, request) {
2038
- // eslint-disable-next-line no-eq-null,eqeqeq
2039
- AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2040
- this.name = 'CanceledError';
2008
+ class CanceledError extends AxiosError$1 {
2009
+ /**
2010
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
2011
+ *
2012
+ * @param {string=} message The message.
2013
+ * @param {Object=} config The config.
2014
+ * @param {Object=} request The request.
2015
+ *
2016
+ * @returns {CanceledError} The created error.
2017
+ */
2018
+ constructor(message, config, request) {
2019
+ super(message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
2020
+ this.name = 'CanceledError';
2021
+ this.__CANCEL__ = true;
2022
+ }
2041
2023
  }
2042
2024
 
2043
- utils$1.inherits(CanceledError, AxiosError, {
2044
- __CANCEL__: true
2045
- });
2025
+ var CanceledError$1 = CanceledError;
2046
2026
 
2047
2027
  /**
2048
2028
  * Resolve or reject a Promise based on response status.
@@ -2058,9 +2038,9 @@ function settle(resolve, reject, response) {
2058
2038
  if (!response.status || !validateStatus || validateStatus(response.status)) {
2059
2039
  resolve(response);
2060
2040
  } else {
2061
- reject(new AxiosError(
2041
+ reject(new AxiosError$1(
2062
2042
  'Request failed with status code ' + response.status,
2063
- [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2043
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2064
2044
  response.config,
2065
2045
  response.request,
2066
2046
  response
@@ -2336,7 +2316,7 @@ function mergeConfig(config1, config2) {
2336
2316
 
2337
2317
  function getMergedValue(target, source, prop, caseless) {
2338
2318
  if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2339
- return utils$1.merge.call({caseless}, target, source);
2319
+ return utils$1.merge.call({ caseless }, target, source);
2340
2320
  } else if (utils$1.isPlainObject(source)) {
2341
2321
  return utils$1.merge({}, source);
2342
2322
  } else if (utils$1.isArray(source)) {
@@ -2345,7 +2325,6 @@ function mergeConfig(config1, config2) {
2345
2325
  return source;
2346
2326
  }
2347
2327
 
2348
- // eslint-disable-next-line consistent-return
2349
2328
  function mergeDeepProperties(a, b, prop, caseless) {
2350
2329
  if (!utils$1.isUndefined(b)) {
2351
2330
  return getMergedValue(a, b, prop, caseless);
@@ -2411,7 +2390,7 @@ function mergeConfig(config1, config2) {
2411
2390
  headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
2412
2391
  };
2413
2392
 
2414
- utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
2393
+ utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
2415
2394
  const merge = mergeMap[prop] || mergeDeepProperties;
2416
2395
  const configValue = merge(config1[prop], config2[prop], prop);
2417
2396
  (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
@@ -2560,7 +2539,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2560
2539
  return;
2561
2540
  }
2562
2541
 
2563
- reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
2542
+ reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
2564
2543
 
2565
2544
  // Clean up request
2566
2545
  request = null;
@@ -2572,7 +2551,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2572
2551
  // (message may be empty; when present, surface it)
2573
2552
  // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
2574
2553
  const msg = event && event.message ? event.message : 'Network Error';
2575
- const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
2554
+ const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
2576
2555
  // attach the underlying event for consumers who want details
2577
2556
  err.event = event || null;
2578
2557
  reject(err);
@@ -2586,9 +2565,9 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2586
2565
  if (_config.timeoutErrorMessage) {
2587
2566
  timeoutErrorMessage = _config.timeoutErrorMessage;
2588
2567
  }
2589
- reject(new AxiosError(
2568
+ reject(new AxiosError$1(
2590
2569
  timeoutErrorMessage,
2591
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
2570
+ transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
2592
2571
  config,
2593
2572
  request));
2594
2573
 
@@ -2638,7 +2617,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2638
2617
  if (!request) {
2639
2618
  return;
2640
2619
  }
2641
- reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
2620
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
2642
2621
  request.abort();
2643
2622
  request = null;
2644
2623
  };
@@ -2652,7 +2631,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2652
2631
  const protocol = parseProtocol(_config.url);
2653
2632
 
2654
2633
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
2655
- reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
2634
+ reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
2656
2635
  return;
2657
2636
  }
2658
2637
 
@@ -2675,13 +2654,13 @@ const composeSignals = (signals, timeout) => {
2675
2654
  aborted = true;
2676
2655
  unsubscribe();
2677
2656
  const err = reason instanceof Error ? reason : this.reason;
2678
- controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
2657
+ controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
2679
2658
  }
2680
2659
  };
2681
2660
 
2682
2661
  let timer = timeout && setTimeout(() => {
2683
2662
  timer = null;
2684
- onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
2663
+ onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
2685
2664
  }, timeout);
2686
2665
 
2687
2666
  const unsubscribe = () => {
@@ -2867,7 +2846,7 @@ const factory = (env) => {
2867
2846
  return method.call(res);
2868
2847
  }
2869
2848
 
2870
- throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
2849
+ throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
2871
2850
  });
2872
2851
  });
2873
2852
  })());
@@ -3033,14 +3012,14 @@ const factory = (env) => {
3033
3012
 
3034
3013
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3035
3014
  throw Object.assign(
3036
- new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
3015
+ new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
3037
3016
  {
3038
3017
  cause: err.cause || err
3039
3018
  }
3040
3019
  )
3041
3020
  }
3042
3021
 
3043
- throw AxiosError.from(err, err && err.code, config, request);
3022
+ throw AxiosError$1.from(err, err && err.code, config, request);
3044
3023
  }
3045
3024
  }
3046
3025
  };
@@ -3145,7 +3124,7 @@ function getAdapter(adapters, config) {
3145
3124
  adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3146
3125
 
3147
3126
  if (adapter === undefined) {
3148
- throw new AxiosError(`Unknown adapter '${id}'`);
3127
+ throw new AxiosError$1(`Unknown adapter '${id}'`);
3149
3128
  }
3150
3129
  }
3151
3130
 
@@ -3166,7 +3145,7 @@ function getAdapter(adapters, config) {
3166
3145
  (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3167
3146
  'as no adapter specified';
3168
3147
 
3169
- throw new AxiosError(
3148
+ throw new AxiosError$1(
3170
3149
  `There is no suitable adapter to dispatch the request ` + s,
3171
3150
  'ERR_NOT_SUPPORT'
3172
3151
  );
@@ -3205,7 +3184,7 @@ function throwIfCancellationRequested(config) {
3205
3184
  }
3206
3185
 
3207
3186
  if (config.signal && config.signal.aborted) {
3208
- throw new CanceledError(null, config);
3187
+ throw new CanceledError$1(null, config);
3209
3188
  }
3210
3189
  }
3211
3190
 
@@ -3265,7 +3244,7 @@ function dispatchRequest(config) {
3265
3244
  });
3266
3245
  }
3267
3246
 
3268
- const VERSION = "1.13.1";
3247
+ const VERSION = "1.13.3";
3269
3248
 
3270
3249
  const validators$1 = {};
3271
3250
 
@@ -3295,9 +3274,9 @@ validators$1.transitional = function transitional(validator, version, message) {
3295
3274
  // eslint-disable-next-line func-names
3296
3275
  return (value, opt, opts) => {
3297
3276
  if (validator === false) {
3298
- throw new AxiosError(
3277
+ throw new AxiosError$1(
3299
3278
  formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
3300
- AxiosError.ERR_DEPRECATED
3279
+ AxiosError$1.ERR_DEPRECATED
3301
3280
  );
3302
3281
  }
3303
3282
 
@@ -3336,7 +3315,7 @@ validators$1.spelling = function spelling(correctSpelling) {
3336
3315
 
3337
3316
  function assertOptions(options, schema, allowUnknown) {
3338
3317
  if (typeof options !== 'object') {
3339
- throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
3318
+ throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
3340
3319
  }
3341
3320
  const keys = Object.keys(options);
3342
3321
  let i = keys.length;
@@ -3347,12 +3326,12 @@ function assertOptions(options, schema, allowUnknown) {
3347
3326
  const value = options[opt];
3348
3327
  const result = value === undefined || validator(value, opt, options);
3349
3328
  if (result !== true) {
3350
- throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
3329
+ throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
3351
3330
  }
3352
3331
  continue;
3353
3332
  }
3354
3333
  if (allowUnknown !== true) {
3355
- throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
3334
+ throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
3356
3335
  }
3357
3336
  }
3358
3337
  }
@@ -3510,8 +3489,13 @@ class Axios {
3510
3489
 
3511
3490
  promise = Promise.resolve(config);
3512
3491
 
3492
+ let prevResult = config;
3513
3493
  while (i < len) {
3514
- promise = promise.then(chain[i++], chain[i++]);
3494
+ promise = promise
3495
+ .then(chain[i++])
3496
+ .then(result => { prevResult = result !== undefined ? result : prevResult; })
3497
+ .catch(chain[i++])
3498
+ .then(() => prevResult);
3515
3499
  }
3516
3500
 
3517
3501
  return promise;
@@ -3542,7 +3526,7 @@ class Axios {
3542
3526
  len = responseInterceptorChain.length;
3543
3527
 
3544
3528
  while (i < len) {
3545
- promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
3529
+ promise = promise.then(responseInterceptorChain[i++]).catch(responseInterceptorChain[i++]);
3546
3530
  }
3547
3531
 
3548
3532
  return promise;
@@ -3645,7 +3629,7 @@ class CancelToken {
3645
3629
  return;
3646
3630
  }
3647
3631
 
3648
- token.reason = new CanceledError(message, config, request);
3632
+ token.reason = new CanceledError$1(message, config, request);
3649
3633
  resolvePromise(token.reason);
3650
3634
  });
3651
3635
  }
@@ -3729,7 +3713,7 @@ var CancelToken$1 = CancelToken;
3729
3713
  *
3730
3714
  * ```js
3731
3715
  * function f(x, y, z) {}
3732
- * var args = [1, 2, 3];
3716
+ * const args = [1, 2, 3];
3733
3717
  * f.apply(null, args);
3734
3718
  * ```
3735
3719
  *
@@ -3870,14 +3854,14 @@ const axios = createInstance(defaults$1);
3870
3854
  axios.Axios = Axios$1;
3871
3855
 
3872
3856
  // Expose Cancel & CancelToken
3873
- axios.CanceledError = CanceledError;
3857
+ axios.CanceledError = CanceledError$1;
3874
3858
  axios.CancelToken = CancelToken$1;
3875
3859
  axios.isCancel = isCancel;
3876
3860
  axios.VERSION = VERSION;
3877
3861
  axios.toFormData = toFormData;
3878
3862
 
3879
3863
  // Expose AxiosError class
3880
- axios.AxiosError = AxiosError;
3864
+ axios.AxiosError = AxiosError$1;
3881
3865
 
3882
3866
  // alias for CanceledError for backward compatibility
3883
3867
  axios.Cancel = axios.CanceledError;