axios 1.4.0 → 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,28 @@
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
+
3
26
  # [1.4.0](https://github.com/axios/axios/compare/v1.3.6...v1.4.0) (2023-04-27)
4
27
 
5
28
 
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.4.0 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);
@@ -1361,10 +1362,6 @@
1361
1362
  return null;
1362
1363
  }
1363
1364
 
1364
- var DEFAULT_CONTENT_TYPE = {
1365
- 'Content-Type': undefined
1366
- };
1367
-
1368
1365
  /**
1369
1366
  * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1370
1367
  * of the input
@@ -1390,7 +1387,7 @@
1390
1387
  }
1391
1388
  var defaults = {
1392
1389
  transitional: transitionalDefaults,
1393
- adapter: ['xhr', 'http'],
1390
+ adapter: platform.isNode ? 'http' : 'xhr',
1394
1391
  transformRequest: [function transformRequest(data, headers) {
1395
1392
  var contentType = headers.getContentType() || '';
1396
1393
  var hasJSONContentType = contentType.indexOf('application/json') > -1;
@@ -1471,16 +1468,14 @@
1471
1468
  },
1472
1469
  headers: {
1473
1470
  common: {
1474
- 'Accept': 'application/json, text/plain, */*'
1471
+ 'Accept': 'application/json, text/plain, */*',
1472
+ 'Content-Type': undefined
1475
1473
  }
1476
1474
  }
1477
1475
  };
1478
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1476
+ utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], function (method) {
1479
1477
  defaults.headers[method] = {};
1480
1478
  });
1481
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1482
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1483
- });
1484
1479
  var defaults$1 = defaults;
1485
1480
 
1486
1481
  // RawAxiosHeaders whose duplicates are ignored by node
@@ -1781,7 +1776,20 @@
1781
1776
  return AxiosHeaders;
1782
1777
  }(Symbol.iterator, Symbol.toStringTag);
1783
1778
  AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1784
- 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
+ });
1785
1793
  utils.freezeMethods(AxiosHeaders);
1786
1794
  var AxiosHeaders$1 = AxiosHeaders;
1787
1795
 
@@ -2440,7 +2448,7 @@
2440
2448
  return config;
2441
2449
  }
2442
2450
 
2443
- var VERSION = "1.4.0";
2451
+ var VERSION = "1.5.0";
2444
2452
 
2445
2453
  var validators$1 = {};
2446
2454
 
@@ -2582,11 +2590,10 @@
2582
2590
 
2583
2591
  // Set config.method
2584
2592
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2585
- var contextHeaders;
2586
2593
 
2587
2594
  // Flatten headers
2588
- contextHeaders = headers && utils.merge(headers.common, headers[config.method]);
2589
- 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) {
2590
2597
  delete headers[method];
2591
2598
  });
2592
2599
  config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
@@ -2973,6 +2980,7 @@
2973
2980
  axios.formToJSON = function (thing) {
2974
2981
  return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
2975
2982
  };
2983
+ axios.getAdapter = adapters.getAdapter;
2976
2984
  axios.HttpStatusCode = HttpStatusCode$1;
2977
2985
  axios["default"] = axios;
2978
2986