axios 1.3.6 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

package/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # Changelog
2
2
 
3
+ # [1.5.0](https://github.com/axios/axios/compare/v1.4.0...v1.5.0) (2023-08-26)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **adapter:** make adapter loading error more clear by using platform-specific adapters explicitly ([#5837](https://github.com/axios/axios/issues/5837)) ([9a414bb](https://github.com/axios/axios/commit/9a414bb6c81796a95c6c7fe668637825458e8b6d))
9
+ * **dns:** fixed `cacheable-lookup` integration; ([#5836](https://github.com/axios/axios/issues/5836)) ([b3e327d](https://github.com/axios/axios/commit/b3e327dcc9277bdce34c7ef57beedf644b00d628))
10
+ * **headers:** added support for setting header names that overlap with class methods; ([#5831](https://github.com/axios/axios/issues/5831)) ([d8b4ca0](https://github.com/axios/axios/commit/d8b4ca0ea5f2f05efa4edfe1e7684593f9f68273))
11
+ * **headers:** fixed common Content-Type header merging; ([#5832](https://github.com/axios/axios/issues/5832)) ([8fda276](https://github.com/axios/axios/commit/8fda2766b1e6bcb72c3fabc146223083ef13ce17))
12
+
13
+
14
+ ### Features
15
+
16
+ * export getAdapter function ([#5324](https://github.com/axios/axios/issues/5324)) ([ca73eb8](https://github.com/axios/axios/commit/ca73eb878df0ae2dace81fe3a7f1fb5986231bf1))
17
+ * **export:** export adapters without `unsafe` prefix ([#5839](https://github.com/axios/axios/issues/5839)) ([1601f4a](https://github.com/axios/axios/commit/1601f4a27a81ab47fea228f1e244b2c4e3ce28bf))
18
+
19
+ ### Contributors to this release
20
+
21
+ - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+66/-29 (#5839 #5837 #5836 #5832 #5831 )")
22
+ - <img src="https://avatars.githubusercontent.com/u/102841186?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [夜葬](https://github.com/geekact "+42/-0 (#5324 )")
23
+ - <img src="https://avatars.githubusercontent.com/u/65978976?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Jonathan Budiman](https://github.com/JBudiman00 "+30/-0 (#5788 )")
24
+ - <img src="https://avatars.githubusercontent.com/u/5492927?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-5 (#5791 )")
25
+
26
+ # [1.4.0](https://github.com/axios/axios/compare/v1.3.6...v1.4.0) (2023-04-27)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * **formdata:** add `multipart/form-data` content type for FormData payload on custom client environments; ([#5678](https://github.com/axios/axios/issues/5678)) ([bbb61e7](https://github.com/axios/axios/commit/bbb61e70cb1185adfb1cbbb86eaf6652c48d89d1))
32
+ * **package:** export package internals with unsafe path prefix; ([#5677](https://github.com/axios/axios/issues/5677)) ([df38c94](https://github.com/axios/axios/commit/df38c949f26414d88ba29ec1e353c4d4f97eaf09))
33
+
34
+
35
+ ### Features
36
+
37
+ * **dns:** added support for a custom lookup function; ([#5339](https://github.com/axios/axios/issues/5339)) ([2701911](https://github.com/axios/axios/commit/2701911260a1faa5cc5e1afe437121b330a3b7bb))
38
+ * **types:** export `AxiosHeaderValue` type. ([#5525](https://github.com/axios/axios/issues/5525)) ([726f1c8](https://github.com/axios/axios/commit/726f1c8e00cffa0461a8813a9bdcb8f8b9d762cf))
39
+
40
+
41
+ ### Performance Improvements
42
+
43
+ * **merge-config:** optimize mergeConfig performance by avoiding duplicate key visits; ([#5679](https://github.com/axios/axios/issues/5679)) ([e6f7053](https://github.com/axios/axios/commit/e6f7053bf1a3e87cf1f9da8677e12e3fe829d68e))
44
+
45
+ ### Contributors to this release
46
+
47
+ - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+151/-16 (#5684 #5339 #5679 #5678 #5677 )")
48
+ - <img src="https://avatars.githubusercontent.com/u/47537704?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Arthur Fiorette](https://github.com/arthurfiorette "+19/-19 (#5525 )")
49
+ - <img src="https://avatars.githubusercontent.com/u/43876655?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [PIYUSH NEGI](https://github.com/npiyush97 "+2/-18 (#5670 )")
50
+
3
51
  ## [1.3.6](https://github.com/axios/axios/compare/v1.3.5...v1.3.6) (2023-04-19)
4
52
 
5
53
 
package/README.md CHANGED
@@ -215,7 +215,7 @@ async function getUser() {
215
215
  }
216
216
  ```
217
217
 
218
- > **Note** `async/await` is part of ECMAScript 2017 and is not supported in Internet
218
+ > **Note**: `async/await` is part of ECMAScript 2017 and is not supported in Internet
219
219
  > Explorer and older browsers, so use with caution.
220
220
 
221
221
  Performing a `POST` request
@@ -764,6 +764,36 @@ and when the response was fulfilled
764
764
 
765
765
  Read [the interceptor tests](./test/specs/interceptors.spec.js) for seeing all this in code.
766
766
 
767
+ ## Error Types
768
+
769
+ There are many different axios error messages that can appear that can provide basic information about the specifics of the error and where opportunities may lie in debugging.
770
+
771
+ The general structure of axios errors is as follows:
772
+ | Property | Definition |
773
+ | -------- | ---------- |
774
+ | message | A quick summary of the error message and the status it failed with. |
775
+ | name | This defines where the error originated from. For axios, it will always be an 'AxiosError'. |
776
+ | stack | Provides the stack trace of the error. |
777
+ | config | An axios config object with specific instance configurations defined by the user from when the request was made |
778
+ | code | Represents an axios identified error. The table below lists out specific definitions for internal axios error. |
779
+ | status | HTTP response status code. See [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for common HTTP response status code meanings.
780
+
781
+ Below is a list of potential axios identified error
782
+ | Code | Definition |
783
+ | -------- | ---------- |
784
+ | ERR_BAD_OPTION_VALUE | Invalid or unsupported value provided in axios configuration. |
785
+ | ERR_BAD_OPTION | Invalid option provided in axios configuration. |
786
+ | ECONNABORTED | Request timed out due to exceeding timeout specified in axios configuration. |
787
+ | ETIMEDOUT | Request timed out due to exceeding default axios timelimit. |
788
+ | ERR_NETWORK | Network-related issue.
789
+ | ERR_FR_TOO_MANY_REDIRECTS | Request is redirected too many times; exceeds max redirects specified in axios configuration.
790
+ | ERR_DEPRECATED | Deprecated feature or method used in axios.
791
+ | ERR_BAD_RESPONSE | Response cannot be parsed properly or is in an unexpected format.
792
+ | ERR_BAD_REQUEST | Requested has unexpected format or missing required parameters. |
793
+ | ERR_CANCELED | Feature or method is canceled explicitly by the user.
794
+ | ERR_NOT_SUPPORT | Feature or method not supported in the current axios environment.
795
+ | ERR_INVALID_URL | Invalid URL provided for axios request.
796
+
767
797
  ## Handling Errors
768
798
 
769
799
  the default behavior is to reject every response that returns with a status code that falls out of the range of 2xx and treat it as an error.
@@ -931,8 +961,7 @@ axios.post('https://something.com/', querystring.stringify({ foo: 'bar' }));
931
961
 
932
962
  You can also use the [`qs`](https://github.com/ljharb/qs) library.
933
963
 
934
- > **Note**
935
- > The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has [known issues](https://github.com/nodejs/node-v0.x-archive/issues/1665) with that use case.
964
+ > **Note**: The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has [known issues](https://github.com/nodejs/node-v0.x-archive/issues/1665) with that use case.
936
965
 
937
966
  ### 🆕 Automatic serialization to URLSearchParams
938
967
 
@@ -1048,8 +1077,7 @@ Axios FormData serializer supports some special endings to perform the following
1048
1077
  - `{}` - serialize the value with JSON.stringify
1049
1078
  - `[]` - unwrap the array-like object as separate fields with the same key
1050
1079
 
1051
- > **Note**
1052
- > unwrap/expand operation will be used by default on arrays and FileList objects
1080
+ > **Note**: unwrap/expand operation will be used by default on arrays and FileList objects
1053
1081
 
1054
1082
  FormData serializer supports additional options via `config.formSerializer: object` property to handle rare cases:
1055
1083
 
package/dist/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- // Axios v1.3.6 Copyright (c) 2023 Matt Zabriskie and contributors
1
+ // Axios v1.5.0 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -625,8 +625,9 @@
625
625
  var descriptors = Object.getOwnPropertyDescriptors(obj);
626
626
  var reducedDescriptors = {};
627
627
  forEach(descriptors, function (descriptor, name) {
628
- if (reducer(descriptor, name, obj) !== false) {
629
- reducedDescriptors[name] = descriptor;
628
+ var ret;
629
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
630
+ reducedDescriptors[name] = ret || descriptor;
630
631
  }
631
632
  });
632
633
  Object.defineProperties(obj, reducedDescriptors);
@@ -722,6 +723,10 @@
722
723
  };
723
724
  return visit(obj, 0);
724
725
  };
726
+ var isAsyncFn = kindOfTest('AsyncFunction');
727
+ var isThenable = function isThenable(thing) {
728
+ return thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing["catch"]);
729
+ };
725
730
  var utils = {
726
731
  isArray: isArray,
727
732
  isArrayBuffer: isArrayBuffer,
@@ -772,7 +777,9 @@
772
777
  ALPHABET: ALPHABET,
773
778
  generateString: generateString,
774
779
  isSpecCompliantForm: isSpecCompliantForm,
775
- toJSONObject: toJSONObject
780
+ toJSONObject: toJSONObject,
781
+ isAsyncFn: isAsyncFn,
782
+ isThenable: isThenable
776
783
  };
777
784
 
778
785
  /**
@@ -1355,10 +1362,6 @@
1355
1362
  return null;
1356
1363
  }
1357
1364
 
1358
- var DEFAULT_CONTENT_TYPE = {
1359
- 'Content-Type': undefined
1360
- };
1361
-
1362
1365
  /**
1363
1366
  * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1364
1367
  * of the input
@@ -1384,7 +1387,7 @@
1384
1387
  }
1385
1388
  var defaults = {
1386
1389
  transitional: transitionalDefaults,
1387
- adapter: ['xhr', 'http'],
1390
+ adapter: platform.isNode ? 'http' : 'xhr',
1388
1391
  transformRequest: [function transformRequest(data, headers) {
1389
1392
  var contentType = headers.getContentType() || '';
1390
1393
  var hasJSONContentType = contentType.indexOf('application/json') > -1;
@@ -1465,16 +1468,14 @@
1465
1468
  },
1466
1469
  headers: {
1467
1470
  common: {
1468
- 'Accept': 'application/json, text/plain, */*'
1471
+ 'Accept': 'application/json, text/plain, */*',
1472
+ 'Content-Type': undefined
1469
1473
  }
1470
1474
  }
1471
1475
  };
1472
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1476
+ utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], function (method) {
1473
1477
  defaults.headers[method] = {};
1474
1478
  });
1475
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1476
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1477
- });
1478
1479
  var defaults$1 = defaults;
1479
1480
 
1480
1481
  // RawAxiosHeaders whose duplicates are ignored by node
@@ -1775,7 +1776,20 @@
1775
1776
  return AxiosHeaders;
1776
1777
  }(Symbol.iterator, Symbol.toStringTag);
1777
1778
  AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1778
- utils.freezeMethods(AxiosHeaders.prototype);
1779
+
1780
+ // reserved names hotfix
1781
+ utils.reduceDescriptors(AxiosHeaders.prototype, function (_ref3, key) {
1782
+ var value = _ref3.value;
1783
+ var mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1784
+ return {
1785
+ get: function get() {
1786
+ return value;
1787
+ },
1788
+ set: function set(headerValue) {
1789
+ this[mapped] = headerValue;
1790
+ }
1791
+ };
1792
+ });
1779
1793
  utils.freezeMethods(AxiosHeaders);
1780
1794
  var AxiosHeaders$1 = AxiosHeaders;
1781
1795
 
@@ -2061,8 +2075,12 @@
2061
2075
  config.signal.removeEventListener('abort', onCanceled);
2062
2076
  }
2063
2077
  }
2064
- if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
2065
- requestHeaders.setContentType(false); // Let the browser set it
2078
+ if (utils.isFormData(requestData)) {
2079
+ if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
2080
+ requestHeaders.setContentType(false); // Let the browser set it
2081
+ } else {
2082
+ requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
2083
+ }
2066
2084
  }
2067
2085
 
2068
2086
  var request = new XMLHttpRequest();
@@ -2422,7 +2440,7 @@
2422
2440
  return mergeDeepProperties(headersToObject(a), headersToObject(b), true);
2423
2441
  }
2424
2442
  };
2425
- utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
2443
+ utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2426
2444
  var merge = mergeMap[prop] || mergeDeepProperties;
2427
2445
  var configValue = merge(config1[prop], config2[prop], prop);
2428
2446
  utils.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
@@ -2430,7 +2448,7 @@
2430
2448
  return config;
2431
2449
  }
2432
2450
 
2433
- var VERSION = "1.3.6";
2451
+ var VERSION = "1.5.0";
2434
2452
 
2435
2453
  var validators$1 = {};
2436
2454
 
@@ -2572,11 +2590,10 @@
2572
2590
 
2573
2591
  // Set config.method
2574
2592
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2575
- var contextHeaders;
2576
2593
 
2577
2594
  // Flatten headers
2578
- contextHeaders = headers && utils.merge(headers.common, headers[config.method]);
2579
- contextHeaders && utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function (method) {
2595
+ var contextHeaders = headers && utils.merge(headers.common, headers[config.method]);
2596
+ headers && utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function (method) {
2580
2597
  delete headers[method];
2581
2598
  });
2582
2599
  config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
@@ -2963,6 +2980,7 @@
2963
2980
  axios.formToJSON = function (thing) {
2964
2981
  return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
2965
2982
  };
2983
+ axios.getAdapter = adapters.getAdapter;
2966
2984
  axios.HttpStatusCode = HttpStatusCode$1;
2967
2985
  axios["default"] = axios;
2968
2986