axios 1.21.0 → 1.22.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.
- package/CHANGELOG.md +68 -0
- package/README.md +58 -47
- package/dist/axios.js +187 -24
- package/dist/axios.min.js +3 -3
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +206 -17
- package/dist/esm/axios.js +206 -17
- package/dist/esm/axios.min.js +2 -2
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +430 -112
- package/index.d.cts +24 -4
- package/index.d.ts +19 -4
- package/lib/adapters/adapters.js +21 -0
- package/lib/adapters/fetch.js +72 -3
- package/lib/adapters/http.js +181 -41
- package/lib/core/Axios.js +6 -0
- package/lib/core/AxiosHeaders.js +1 -0
- package/lib/core/InterceptorManager.js +7 -2
- package/lib/core/assertValidRequestUrl.js +62 -0
- package/lib/core/dispatchRequest.js +31 -10
- package/lib/env/data.js +1 -1
- package/lib/helpers/combineURLs.js +8 -0
- package/lib/helpers/proxyFromEnv.js +158 -0
- package/lib/helpers/shouldBypassProxy.js +2 -1
- package/lib/helpers/trackStream.js +5 -0
- package/package.json +25 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.21.0 — October 21, 2026
|
|
4
|
+
|
|
5
|
+
This release adds response timing and opt-in UTF-8 Basic authentication, improves request handling across runtimes, and changes how header defaults are recognized.
|
|
6
|
+
|
|
7
|
+
## ⚠️ Breaking Changes & Deprecations
|
|
8
|
+
|
|
9
|
+
* **Header Defaults:** Only plain objects, null-prototype maps, and compatible `AxiosHeaders` instances are treated as common or method-specific defaults; literal headers such as `Link` are now preserved. Applications using custom class instances as defaults must convert them to plain maps, for example `{ post: { ...customDefaults } }`, or compatible `AxiosHeaders`. Otherwise, those instances become literal header values, including on requests using other methods. (**[#11156](https://github.com/axios/axios/pull/11156)**)
|
|
10
|
+
|
|
11
|
+
## 🚀 New Features
|
|
12
|
+
|
|
13
|
+
* **Response Timing:** Added `response.duration`, in milliseconds, including on `error.response` when present. Timing measures adapter execution and excludes interceptors and transforms; streamed responses stop timing when the stream becomes available. Axios replaces any existing `duration` value supplied by a custom adapter. (**[#11214](https://github.com/axios/axios/pull/11214)**)
|
|
14
|
+
* **UTF-8 Basic Authentication:** Added `transitional.encodeBasicAuthUsername: true` to support Unicode usernames in XHR and Fetch requests. The option defaults to `false`, preserving existing authentication behavior; applications opting in should supply the original Unicode username and remove manual pre-encoding workarounds. (**[#11159](https://github.com/axios/axios/pull/11159)**)
|
|
15
|
+
|
|
16
|
+
## 🐛 Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **Fetch Compatibility:** Restored requests in runtimes such as Cloudflare Workers that reject the implicit `cache: 'default'`, while preserving explicit caller settings. Response-size failures now retain their original `ERR_BAD_RESPONSE` and request context when runtime wrappers replace the underlying stream error. (**[#11194](https://github.com/axios/axios/pull/11194)**, **[#11179](https://github.com/axios/axios/pull/11179)**)
|
|
19
|
+
* **Runtime Consistency:** Aligned encoded-byte size accounting, multipart uploads, proxy routing, same-origin resolution, parameter merging, and form serialization across adapters. Circular parameters now reject with `ERR_BAD_OPTION_VALUE`, and sparse or non-index numeric form fields serialize as keyed objects. With `proxy: false`, native `proxyEnv` agents using unsupported pool-management or TLS-session lifecycle overrides now reject with `ERR_BAD_OPTION_VALUE`; construct those agents without `proxyEnv`. (**[#11242](https://github.com/axios/axios/pull/11242)**)
|
|
20
|
+
* **Header Handling:** Preserved headers named **`__proto__`** using safe casing without changing the `AxiosHeaders` instance prototype. Function matchers in `has()`, `delete()`, and `clear()` now receive the headers instance as `this`, matching their declared contract. (**[#11134](https://github.com/axios/axios/pull/11134)**, **[#11216](https://github.com/axios/axios/pull/11216)**)
|
|
21
|
+
* **URL and Data URL Parsing:** Accepted case-insensitive supported URL schemes and Base64 markers, and corrected decoding of percent-encoded Base64 data URLs. Node data URL allocation estimates remain aligned with decoding so configured size limits apply before allocation. (**[#11138](https://github.com/axios/axios/pull/11138)**, **[#11163](https://github.com/axios/axios/pull/11163)**, **[#11294](https://github.com/axios/axios/pull/11294)**)
|
|
22
|
+
* **Error Diagnostics:** Preserved short reconstructed request stacks and appended wrapped error stacks under `Caused by:` so tooling that reads only `error.stack` retains the original failure context. (**[#11132](https://github.com/axios/axios/pull/11132)**, **[#11142](https://github.com/axios/axios/pull/11142)**)
|
|
23
|
+
* **Interceptor Removal:** Restored removal through canonical numeric-string interceptor IDs, including after registry compaction. (**[#11139](https://github.com/axios/axios/pull/11139)**)
|
|
24
|
+
* **Proxy TLS:** HTTPS CONNECT tunnels now apply current origin TLS options from an explicit `httpsAgent`, or from `https.globalAgent` when no explicit agent is supplied. This preserves process-wide custom CA settings through proxy tunnels. (**[#11178](https://github.com/axios/axios/pull/11178)**)
|
|
25
|
+
* **XHR Lifecycle:** Used asynchronous Cookie Store reads for XSRF tokens where supported, preserving cookie fallback, timeout accounting, and cancellation. Upload and download progress listeners are now removed on completion, failure, timeout, and cancellation. (**[#11166](https://github.com/axios/axios/pull/11166)**, **[#11225](https://github.com/axios/axios/pull/11225)**)
|
|
26
|
+
* **HTTP/2 Sessions:** Stopped reusing sessions immediately after GOAWAY and prevented draining sessions from scheduling idle timers that could delay process exit. (**[#11210](https://github.com/axios/axios/pull/11210)**)
|
|
27
|
+
* **TypeScript Declarations:** Exposed the response-default marker as a public type to resolve `TS2527` when consumers emit declarations involving unresolved response generics, covering both ESM and CommonJS. (**[#11125](https://github.com/axios/axios/pull/11125)**)
|
|
28
|
+
|
|
29
|
+
## 🔧 Maintenance & Chores
|
|
30
|
+
|
|
31
|
+
* **Configuration Performance:** Reduced request configuration merge overhead, particularly for requests with many headers, while preserving merge semantics and prototype-pollution guards. (**[#11208](https://github.com/axios/axios/pull/11208)**)
|
|
32
|
+
* **Same-Origin Checks:** Removed obsolete Internet Explorer detection without changing origin decisions in supported environments. (**[#11174](https://github.com/axios/axios/pull/11174)**)
|
|
33
|
+
* **Dependencies:** Updated `follow-redirects` to 1.16.1 and refreshed development, documentation, test, and GitHub Actions dependencies. Removed unused `dayjs` from the docs package, root `chalk`, and `chai` from CJS module tests. (**[#11169](https://github.com/axios/axios/pull/11169)**, **[#11188](https://github.com/axios/axios/pull/11188)**, **[#11189](https://github.com/axios/axios/pull/11189)**, **[#11195](https://github.com/axios/axios/pull/11195)**, **[#11212](https://github.com/axios/axios/pull/11212)**, **[#11213](https://github.com/axios/axios/pull/11213)**, **[#11218](https://github.com/axios/axios/pull/11218)**, **[#11220](https://github.com/axios/axios/pull/11220)**, **[#11221](https://github.com/axios/axios/pull/11221)**, **[#11230](https://github.com/axios/axios/pull/11230)**, **[#11234](https://github.com/axios/axios/pull/11234)**, **[#11244](https://github.com/axios/axios/pull/11244)**, **[#11245](https://github.com/axios/axios/pull/11245)**, **[#11266](https://github.com/axios/axios/pull/11266)**, **[#11267](https://github.com/axios/axios/pull/11267)**, **[#11268](https://github.com/axios/axios/pull/11268)**, **[#11269](https://github.com/axios/axios/pull/11269)**, **[#11270](https://github.com/axios/axios/pull/11270)**, **[#11271](https://github.com/axios/axios/pull/11271)**, **[#11272](https://github.com/axios/axios/pull/11272)**, **[#11298](https://github.com/axios/axios/pull/11298)**, **[#11302](https://github.com/axios/axios/pull/11302)**, **[#11303](https://github.com/axios/axios/pull/11303)**, **[#11304](https://github.com/axios/axios/pull/11304)**, **[#11305](https://github.com/axios/axios/pull/11305)**, **[#11306](https://github.com/axios/axios/pull/11306)**, **[#11313](https://github.com/axios/axios/pull/11313)**, **[#11321](https://github.com/axios/axios/pull/11321)**, **[#11322](https://github.com/axios/axios/pull/11322)**, **[#11323](https://github.com/axios/axios/pull/11323)**, **[#11342](https://github.com/axios/axios/pull/11342)**)
|
|
34
|
+
* **Documentation:** Fixed interceptor test links, updated README CDN examples to the published 1.20.0 bundle, and corrected guidance on interceptor options and request lifecycle ordering. (**[#11228](https://github.com/axios/axios/pull/11228)**, **[#11149](https://github.com/axios/axios/pull/11149)**, **[#11335](https://github.com/axios/axios/pull/11335)**)
|
|
35
|
+
* **Contributor Workflow:** Consolidated agent instructions in `AGENTS.md`, standardized PR labels, required prerelease notes and validation evidence, and clarified that `npm test` requires installed Playwright browsers. (**[#11238](https://github.com/axios/axios/pull/11238)**, **[#11273](https://github.com/axios/axios/pull/11273)**, **[#11223](https://github.com/axios/axios/pull/11223)**, **[#11284](https://github.com/axios/axios/pull/11284)**)
|
|
36
|
+
* **Sponsors and Support:** Added HeroDevs, Code for Japan, and Sweepico sponsor listings, refreshed sponsor data, and documented extended security support for Axios v0. (**[#11222](https://github.com/axios/axios/pull/11222)**, **[#11249](https://github.com/axios/axios/pull/11249)**, **[#11252](https://github.com/axios/axios/pull/11252)**, **[#11341](https://github.com/axios/axios/pull/11341)**)
|
|
37
|
+
* **Proxy Regression Coverage:** Added a long dotted request-hostname test for `NO_PROXY` handling, extending coverage of an existing denial-of-service fix. (**[#11235](https://github.com/axios/axios/pull/11235)**)
|
|
38
|
+
* **Release Preparation:** Updated package version metadata for 1.21.0. (**[#11346](https://github.com/axios/axios/pull/11346)**)
|
|
39
|
+
|
|
40
|
+
## 🌟 New Contributors
|
|
41
|
+
|
|
42
|
+
Welcome to our 24 new contributors. Thank you for helping improve Axios:
|
|
43
|
+
|
|
44
|
+
* **@lazerg** (**[#11194](https://github.com/axios/axios/pull/11194)**)
|
|
45
|
+
* **@QIU-Guanzong** (**[#11228](https://github.com/axios/axios/pull/11228)**)
|
|
46
|
+
* **@Iams4kura** (**[#11125](https://github.com/axios/axios/pull/11125)**)
|
|
47
|
+
* **@vjymisal0** (**[#11179](https://github.com/axios/axios/pull/11179)**)
|
|
48
|
+
* **@jarrensj** (**[#11238](https://github.com/axios/axios/pull/11238)**)
|
|
49
|
+
* **@LineGu** (**[#11132](https://github.com/axios/axios/pull/11132)**)
|
|
50
|
+
* **@luantaraschi** (**[#11134](https://github.com/axios/axios/pull/11134)**)
|
|
51
|
+
* **@Cyberhet** (**[#11284](https://github.com/axios/axios/pull/11284)**)
|
|
52
|
+
* **@nyxst4ck** (**[#11138](https://github.com/axios/axios/pull/11138)**)
|
|
53
|
+
* **@windcrestai** (**[#11163](https://github.com/axios/axios/pull/11163)**)
|
|
54
|
+
* **@kazuki-netizen** (**[#11294](https://github.com/axios/axios/pull/11294)**)
|
|
55
|
+
* **@bilashcse** (**[#11139](https://github.com/axios/axios/pull/11139)**)
|
|
56
|
+
* **@JiuYue0820** (**[#11149](https://github.com/axios/axios/pull/11149)**)
|
|
57
|
+
* **@official-burak** (**[#11156](https://github.com/axios/axios/pull/11156)**)
|
|
58
|
+
* **@contactjawad** (**[#11159](https://github.com/axios/axios/pull/11159)**)
|
|
59
|
+
* **@wittachai-as** (**[#11174](https://github.com/axios/axios/pull/11174)**)
|
|
60
|
+
* **@yiheng-kkk** (**[#11166](https://github.com/axios/axios/pull/11166)**)
|
|
61
|
+
* **@ShikeChen01** (**[#11208](https://github.com/axios/axios/pull/11208)**)
|
|
62
|
+
* **@cuishuang** (**[#11210](https://github.com/axios/axios/pull/11210)**)
|
|
63
|
+
* **@Truenocancion** (**[#11225](https://github.com/axios/axios/pull/11225)**)
|
|
64
|
+
* **@jakezwang** (**[#11216](https://github.com/axios/axios/pull/11216)**)
|
|
65
|
+
* **@Adityagarg2712** (**[#11214](https://github.com/axios/axios/pull/11214)**)
|
|
66
|
+
* **@Zandereins** (**[#11235](https://github.com/axios/axios/pull/11235)**)
|
|
67
|
+
* **@Plastic-time** (**[#11335](https://github.com/axios/axios/pull/11335)**)
|
|
68
|
+
|
|
69
|
+
[Full Changelog](https://github.com/axios/axios/compare/v1.20.0...v1.21.0)
|
|
70
|
+
|
|
3
71
|
## v1.19.0 — July 22, 2026
|
|
4
72
|
|
|
5
73
|
This release raises the form-data security floor, adds configuration and type-system capabilities, and fixes NO_PROXY matching, interceptor errors, progress reporting, and serialization edge cases.
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
> [!IMPORTANT]
|
|
2
|
-
> [**Get Security Updates for Axios v0 →**](https://www.herodevs.com/support/nes-for-axios?utm_source=axios-site&utm_medium=referral&utm_campaign=nes-for-axios_global&utm_content=landing-page_none_20260924_a)
|
|
2
|
+
> [**Get Security Updates for Axios v0 & Early Access Provider →**](https://www.herodevs.com/support/nes-for-axios?utm_source=axios-site&utm_medium=referral&utm_campaign=nes-for-axios_global&utm_content=landing-page_none_20260924_a)
|
|
3
3
|
|
|
4
4
|
<h3 align="center">💎 Platinum sponsors <br /></h3>
|
|
5
5
|
<table align="center">
|
|
@@ -86,33 +86,6 @@
|
|
|
86
86
|
>
|
|
87
87
|
</p>
|
|
88
88
|
</td>
|
|
89
|
-
<td align="center" width="33.333333333333336%">
|
|
90
|
-
<a
|
|
91
|
-
href="https://opensource.sap.com?utm_source=axios&utm_medium=sponsorlist&utm_campaign=sponsorship"
|
|
92
|
-
style="padding: 10px; display: inline-block"
|
|
93
|
-
target="_blank"
|
|
94
|
-
>
|
|
95
|
-
<img
|
|
96
|
-
width="90px"
|
|
97
|
-
height="90px"
|
|
98
|
-
src="https://avatars.githubusercontent.com/u/2531208?s=200&v=4"
|
|
99
|
-
alt="SAP"
|
|
100
|
-
/>
|
|
101
|
-
</a>
|
|
102
|
-
<p
|
|
103
|
-
align="center"
|
|
104
|
-
title="SAP SE, a global software company, is one of the largest vendors of ERP and other enterprise applications."
|
|
105
|
-
>
|
|
106
|
-
BSAP SE, a global software company, is one of the largest vendors of ERP and other enterprise applications.
|
|
107
|
-
</p>
|
|
108
|
-
<p align="center">
|
|
109
|
-
<a
|
|
110
|
-
href="https://opensource.sap.com?utm_source=axios&utm_medium=readme_sponsorlist&utm_campaign=sponsorship"
|
|
111
|
-
target="_blank"
|
|
112
|
-
><b>opensource.sap.com</b></a
|
|
113
|
-
>
|
|
114
|
-
</p>
|
|
115
|
-
</td>
|
|
116
89
|
<td align="center" width="33.333333333333336%">
|
|
117
90
|
<a
|
|
118
91
|
href="https://www.descope.com/?utm_source=axios&utm_medium=referral&utm_campaign=axios-oss-sponsorship"
|
|
@@ -140,8 +113,6 @@
|
|
|
140
113
|
>
|
|
141
114
|
</p>
|
|
142
115
|
</td>
|
|
143
|
-
</tr>
|
|
144
|
-
<tr width="33.333333333333336%">
|
|
145
116
|
<td align="center" width="33.333333333333336%">
|
|
146
117
|
<a
|
|
147
118
|
href="https://rxdb.info/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship&utm_content=logo"
|
|
@@ -168,6 +139,8 @@
|
|
|
168
139
|
>
|
|
169
140
|
</p>
|
|
170
141
|
</td>
|
|
142
|
+
</tr>
|
|
143
|
+
<tr width="33.333333333333336%">
|
|
171
144
|
<td align="center" width="33.333333333333336%">
|
|
172
145
|
<a
|
|
173
146
|
href="https://poprey.com/?utm_source=axios&utm_medium=sponsorlist&utm_campaign=sponsorship"
|
|
@@ -218,8 +191,6 @@
|
|
|
218
191
|
>
|
|
219
192
|
</p>
|
|
220
193
|
</td>
|
|
221
|
-
</tr>
|
|
222
|
-
<tr width="33.333333333333336%">
|
|
223
194
|
<td align="center" width="33.333333333333336%">
|
|
224
195
|
<a
|
|
225
196
|
href="https://www.jbo88b.com/vn/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
@@ -246,6 +217,8 @@
|
|
|
246
217
|
>
|
|
247
218
|
</p>
|
|
248
219
|
</td>
|
|
220
|
+
</tr>
|
|
221
|
+
<tr width="33.333333333333336%">
|
|
249
222
|
<td align="center" width="33.333333333333336%">
|
|
250
223
|
<a
|
|
251
224
|
href="https://www.jbo579.com/th/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
@@ -298,8 +271,6 @@
|
|
|
298
271
|
>
|
|
299
272
|
</p>
|
|
300
273
|
</td>
|
|
301
|
-
</tr>
|
|
302
|
-
<tr width="33.333333333333336%">
|
|
303
274
|
<td align="center" width="33.333333333333336%">
|
|
304
275
|
<a
|
|
305
276
|
href="https://www.herodevs.com/support/nes-for-axios?utm_source=axios-site&utm_medium=referral&utm_campaign=nes-for-axios_global&utm_content=landing-page_none_20260924_a"
|
|
@@ -326,6 +297,8 @@
|
|
|
326
297
|
>
|
|
327
298
|
</p>
|
|
328
299
|
</td>
|
|
300
|
+
</tr>
|
|
301
|
+
<tr width="33.333333333333336%">
|
|
329
302
|
<td align="center" width="33.333333333333336%">
|
|
330
303
|
<a
|
|
331
304
|
href="https://opencollective.com/sweepico-promo-code"
|
|
@@ -352,6 +325,29 @@
|
|
|
352
325
|
>
|
|
353
326
|
</p>
|
|
354
327
|
</td>
|
|
328
|
+
<td align="center" valign="middle" width="33.333333333333336%">
|
|
329
|
+
<a
|
|
330
|
+
href="https://namespace.so/github-actions/?utm_source=oss&utm_campaign=axios"
|
|
331
|
+
style="padding: 10px; display: inline-block"
|
|
332
|
+
target="_blank"
|
|
333
|
+
>
|
|
334
|
+
<img
|
|
335
|
+
width="180px"
|
|
336
|
+
src="https://namespace.so/oss/badge.svg"
|
|
337
|
+
alt="CI powered by Namespace"
|
|
338
|
+
/>
|
|
339
|
+
</a>
|
|
340
|
+
<p align="center">
|
|
341
|
+
Actually the fastest way to run <br>your GitHub Actions.
|
|
342
|
+
</p>
|
|
343
|
+
<p align="center">
|
|
344
|
+
<a
|
|
345
|
+
href="https://namespace.so/github-actions/?utm_source=oss&utm_campaign=axios"
|
|
346
|
+
target="_blank"
|
|
347
|
+
><b>namespace.so</b></a
|
|
348
|
+
>
|
|
349
|
+
</p>
|
|
350
|
+
</td>
|
|
355
351
|
</tr>
|
|
356
352
|
</table>
|
|
357
353
|
|
|
@@ -492,6 +488,12 @@ Using Deno:
|
|
|
492
488
|
$ deno add axios
|
|
493
489
|
```
|
|
494
490
|
|
|
491
|
+
Using vlt:
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
$ vlt install axios
|
|
495
|
+
```
|
|
496
|
+
|
|
495
497
|
Once the package is installed, import it with `import` or `require`:
|
|
496
498
|
|
|
497
499
|
```js
|
|
@@ -770,9 +772,9 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
770
772
|
allowAbsoluteUrls: true,
|
|
771
773
|
|
|
772
774
|
// `transformRequest` allows changes to the request data before it is sent to the server
|
|
773
|
-
//
|
|
775
|
+
// It runs for every request, whatever the request method
|
|
774
776
|
// The last function in the array must return a string or an instance of Buffer, ArrayBuffer,
|
|
775
|
-
// FormData or
|
|
777
|
+
// FormData, Stream, Blob or File
|
|
776
778
|
// You may modify the headers object.
|
|
777
779
|
transformRequest: [function (data, headers) {
|
|
778
780
|
// Do whatever you want to transform the data
|
|
@@ -897,7 +899,7 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
897
899
|
// `responseType` indicates the type of data that the server will respond with
|
|
898
900
|
// options are: 'arraybuffer', 'document', 'json', 'text', 'stream'
|
|
899
901
|
// browser only: 'blob'
|
|
900
|
-
responseType: 'json', // default
|
|
902
|
+
responseType: 'json', // not set by default; see `forcedJSONParsing` below
|
|
901
903
|
|
|
902
904
|
// `responseEncoding` indicates encoding to use for decoding responses (Node.js only)
|
|
903
905
|
// Note: Ignored for `responseType` of 'stream' or client-side requests
|
|
@@ -1118,7 +1120,7 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
1118
1120
|
// try to parse the response string as JSON even if `responseType` is not 'json'
|
|
1119
1121
|
forcedJSONParsing: true,
|
|
1120
1122
|
|
|
1121
|
-
//
|
|
1123
|
+
// Set to true to use ETIMEDOUT for timeouts in the http and xhr adapters.
|
|
1122
1124
|
clarifyTimeoutError: false,
|
|
1123
1125
|
|
|
1124
1126
|
// keep explicit `validateStatus: undefined` resolving every response status
|
|
@@ -1481,7 +1483,7 @@ Axios errors use this structure:
|
|
|
1481
1483
|
| Property | Definition |
|
|
1482
1484
|
| -------- | ---------- |
|
|
1483
1485
|
| message | A quick summary of the error message and the status it failed with. |
|
|
1484
|
-
| name |
|
|
1486
|
+
| name | The error name: usually `AxiosError`, `CanceledError` for cancellations, or the original name of a wrapped error. Use `axios.isAxiosError(error)` to identify Axios errors and `axios.isCancel(error)` to detect cancellations. |
|
|
1485
1487
|
| stack | Stack trace for the error. |
|
|
1486
1488
|
| config | An axios config object with specific instance configurations defined by the user from when the request was made |
|
|
1487
1489
|
| code | Axios error code. The table below lists internal Axios error codes. |
|
|
@@ -1496,13 +1498,15 @@ These are the internal Axios error codes:
|
|
|
1496
1498
|
| ERR_NOT_SUPPORT | Feature or method not supported in the current axios environment. |
|
|
1497
1499
|
| ERR_DEPRECATED | Deprecated feature or method used in axios. |
|
|
1498
1500
|
| ERR_INVALID_URL | Invalid URL provided for axios request. |
|
|
1499
|
-
| ECONNABORTED |
|
|
1501
|
+
| ECONNABORTED | The `http` and `xhr` adapters use this code for timeouts by default. The `xhr` adapter can also use it when the browser aborts a request. |
|
|
1500
1502
|
| ERR_CANCELED | The user explicitly canceled the request with an AbortSignal or CancelToken. |
|
|
1501
|
-
| ETIMEDOUT |
|
|
1502
|
-
|
|
|
1503
|
+
| ETIMEDOUT | For Axios timeout errors, the `fetch` adapter uses this code regardless of `transitional.clarifyTimeoutError`. The `http` and `xhr` adapters use it when that option is `true`. |
|
|
1504
|
+
| ECONNREFUSED | The server refused the connection. Set by the Node.js `http` adapter, with the original system error on `error.cause`; the `xhr` and `fetch` adapters report `ERR_NETWORK` instead. |
|
|
1505
|
+
| ERR_NETWORK | Network-related issue. In the browser, this error can also be caused by a [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS) or [Mixed Content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content) policy violation. The browser does not allow the JS code to clarify the real reason for the error caused by security issues, so please check the console. |
|
|
1503
1506
|
| ERR_FR_TOO_MANY_REDIRECTS | Request exceeded the configured maximum number of redirects. |
|
|
1504
1507
|
| ERR_BAD_RESPONSE | Response cannot be parsed properly or is in an unexpected format. Usually related to a response with `5xx` status code. |
|
|
1505
1508
|
| ERR_BAD_REQUEST | The request has an unexpected format or is missing required parameters. Usually related to a response with `4xx` status code. |
|
|
1509
|
+
| ERR_FORM_DATA_DEPTH_EXCEEDED | An object exceeds the configured `maxDepth` while serializing `params` or form data. Default limit is 100 levels. Parsing FormData into JSON, by `axios.formToJSON()` or when a spec-compliant `FormData` (one with an `entries()` method) or HTML form is sent with `Content-Type: application/json`, has a fixed limit of 100 levels that `maxDepth` does not change. |
|
|
1506
1510
|
|
|
1507
1511
|
## Handling errors
|
|
1508
1512
|
|
|
@@ -1564,7 +1568,7 @@ axios.get('/user/12345').catch(function (error) {
|
|
|
1564
1568
|
});
|
|
1565
1569
|
```
|
|
1566
1570
|
|
|
1567
|
-
To avoid logging secrets from `error.config`, pass a `redact` array in the request config. Matching config keys are masked case-insensitively at any depth when `AxiosError#toJSON()` is called.
|
|
1571
|
+
To avoid logging secrets from `error.config`, pass a `redact` array in the request config. Matching config keys are masked case-insensitively at any depth when `AxiosError#toJSON()` is called. Objects other than plain objects and `AxiosHeaders` that have a `toJSON()` method, such as `URL` objects, are serialized as-is and not scanned, and credentials inside URL strings are not matched. List the parent key, such as `auth` or `proxy`, to mask the whole value.
|
|
1568
1572
|
|
|
1569
1573
|
```js
|
|
1570
1574
|
axios
|
|
@@ -1579,13 +1583,15 @@ axios
|
|
|
1579
1583
|
|
|
1580
1584
|
## Handling timeouts
|
|
1581
1585
|
|
|
1586
|
+
For Axios timeout errors, the `http` and `xhr` adapters reject with `ECONNABORTED` by default. Set `transitional.clarifyTimeoutError: true` to get `ETIMEDOUT` from those adapters. The `fetch` adapter uses `ETIMEDOUT` regardless of this setting.
|
|
1587
|
+
|
|
1582
1588
|
```js
|
|
1583
1589
|
async function fetchWithTimeout() {
|
|
1584
1590
|
try {
|
|
1585
1591
|
const response = await axios.get('https://example.com/data', {
|
|
1586
1592
|
timeout: 5000, // 5 seconds
|
|
1587
1593
|
transitional: {
|
|
1588
|
-
//
|
|
1594
|
+
// Set to true to use ETIMEDOUT for timeouts in the http and xhr adapters.
|
|
1589
1595
|
clarifyTimeoutError: false,
|
|
1590
1596
|
},
|
|
1591
1597
|
});
|
|
@@ -1986,6 +1992,10 @@ console.log(axios.formToJSON(form));
|
|
|
1986
1992
|
|
|
1987
1993
|
`user[name]` also creates `{ user: { name: ... } }`, while `items[]` creates an array.
|
|
1988
1994
|
|
|
1995
|
+
Field names are paths, so names that collide are combined rather than kept apart. A repeated name becomes an array: two `account` fields produce `{ account: ['standard', 'admin'] }`. When a name is used both as a plain value and as a parent path, the result depends on field order. `account=standard` followed by `account[role]=admin` produces `{ account: { role: 'admin' } }`, and the plain value is lost. The reverse order produces `{ account: [{ role: 'admin' }, 'standard'] }`. If you validate submitted fields, check the object `formToJSON()` returns, which is also what axios sends when it serializes `FormData` as JSON, rather than the original `FormData` entries.
|
|
1996
|
+
|
|
1997
|
+
Field names can nest at most 100 levels deep. A deeper name throws an `AxiosError` with code `ERR_FORM_DATA_DEPTH_EXCEEDED`, including when axios sends a spec-compliant `FormData` (one with an `entries()` method) or an HTML form as JSON. The limit is fixed, and `formSerializer.maxDepth` and `paramsSerializer.maxDepth` do not change it.
|
|
1998
|
+
|
|
1989
1999
|
Axios supports `postForm`, `putForm`, and `patchForm` as shortcuts for the matching HTTP methods with the `Content-Type` header preset to `multipart/form-data`.
|
|
1990
2000
|
|
|
1991
2001
|
## Posting files
|
|
@@ -2393,7 +2403,7 @@ Returns `true` if at least one header has been cleared.
|
|
|
2393
2403
|
|
|
2394
2404
|
If the headers object was changed directly, it can have duplicates with the same name but in different cases.
|
|
2395
2405
|
This method normalizes the headers object by combining duplicate keys into one.
|
|
2396
|
-
Axios uses this method internally
|
|
2406
|
+
Axios uses this method internally before calling each request and response transformer, and once more after the transformers run.
|
|
2397
2407
|
Set `format` to true for converting header names to lowercase and capitalizing the initial letters (`cOntEnt-type` => `Content-Type`)
|
|
2398
2408
|
|
|
2399
2409
|
```js
|
|
@@ -2491,8 +2501,9 @@ const fetchAxios = axios.create({
|
|
|
2491
2501
|
const { data } = fetchAxios.get(url);
|
|
2492
2502
|
```
|
|
2493
2503
|
|
|
2494
|
-
|
|
2495
|
-
|
|
2504
|
+
Upload progress requires request stream support and is reported only for methods other than `GET` and `HEAD` with a non-empty request body.
|
|
2505
|
+
Download progress requires response stream support and a readable response body.
|
|
2506
|
+
The adapter also supports response types such as `stream` and `formdata` when the environment supports them.
|
|
2496
2507
|
|
|
2497
2508
|
When `auth` is omitted, the fetch adapter can read HTTP Basic auth credentials from the request URL, for example `https://user:pass@example.com`. Percent-encoded URL credentials are decoded before the `Authorization` header is generated, and `auth` takes precedence over URL-embedded credentials.
|
|
2498
2509
|
|