axios 1.15.2 β 1.16.1
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 +103 -6
- package/README.md +396 -25
- package/dist/axios.js +1455 -1109
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +3 -3
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +1569 -1174
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +1569 -1173
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +2 -2
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +1395 -915
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +25 -13
- package/index.d.ts +21 -4
- package/index.js +2 -0
- package/lib/adapters/adapters.js +4 -2
- package/lib/adapters/fetch.js +131 -11
- package/lib/adapters/http.js +298 -69
- package/lib/adapters/xhr.js +8 -3
- package/lib/core/Axios.js +7 -3
- package/lib/core/AxiosError.js +86 -1
- package/lib/core/AxiosHeaders.js +4 -33
- package/lib/core/dispatchRequest.js +19 -7
- package/lib/core/mergeConfig.js +6 -3
- package/lib/core/settle.js +7 -11
- package/lib/defaults/index.js +1 -1
- package/lib/env/data.js +1 -1
- package/lib/helpers/buildURL.js +1 -1
- package/lib/helpers/composeSignals.js +48 -47
- package/lib/helpers/cookies.js +14 -2
- package/lib/helpers/estimateDataURLDecodedBytes.js +28 -1
- package/lib/helpers/formDataToJSON.js +1 -1
- package/lib/helpers/formDataToStream.js +1 -1
- package/lib/helpers/fromDataURI.js +18 -5
- package/lib/helpers/parseProtocol.js +1 -1
- package/lib/helpers/progressEventReducer.js +3 -0
- package/lib/helpers/resolveConfig.js +33 -17
- package/lib/helpers/sanitizeHeaderValue.js +60 -0
- package/lib/helpers/shouldBypassProxy.js +26 -1
- package/lib/helpers/validator.js +1 -1
- package/lib/utils.js +35 -22
- package/package.json +19 -24
package/README.md
CHANGED
|
@@ -1,32 +1,315 @@
|
|
|
1
|
-
<h3 align="center"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
<h3 align="center">π Platinum sponsors <br /></h3>
|
|
2
|
+
<table align="center">
|
|
3
|
+
<tr>
|
|
4
|
+
<td align="center" width="50%">
|
|
5
|
+
<a
|
|
6
|
+
href="https://thanks.dev/?utm_source=axios&utm_medium=sponsorlist&utm_campaign=sponsorship"
|
|
7
|
+
style="padding: 10px; display: inline-block"
|
|
8
|
+
target="_blank"
|
|
9
|
+
>
|
|
10
|
+
<img
|
|
11
|
+
width="90px"
|
|
12
|
+
height="90px"
|
|
13
|
+
src="https://images.opencollective.com/thanks-dev/360b917/logo/256.png?height=256"
|
|
14
|
+
alt="Thanks.dev"
|
|
15
|
+
/>
|
|
16
|
+
</a>
|
|
17
|
+
<p
|
|
18
|
+
align="center"
|
|
19
|
+
>
|
|
20
|
+
We're passionate about making open source sustainable. Scan your dependency tree to better understand which open source projects need funding.
|
|
21
|
+
</p>
|
|
22
|
+
<p align="center">
|
|
23
|
+
<a
|
|
24
|
+
href="https://thanks.dev/?utm_source=axios&utm_medium=readme_sponsorlist&utm_campaign=sponsorship"
|
|
25
|
+
target="_blank"
|
|
26
|
+
><b>thanks.dev</b></a
|
|
27
|
+
>
|
|
28
|
+
</p>
|
|
29
|
+
</td>
|
|
30
|
+
<td align="center" width="50%">
|
|
31
|
+
<a
|
|
32
|
+
href="https://hopper.security/?utm_source=axios&utm_medium=readme_sponsorlist&utm_campaign=sponsorship"
|
|
33
|
+
style="padding: 10px; display: inline-block"
|
|
34
|
+
target="_blank"
|
|
35
|
+
>
|
|
36
|
+
<img
|
|
37
|
+
width="90px"
|
|
38
|
+
height="90px"
|
|
39
|
+
src="https://images.opencollective.com/hopper-security/c4f7de2/avatar.png"
|
|
40
|
+
alt="Hopper Security"
|
|
41
|
+
/>
|
|
42
|
+
</a>
|
|
43
|
+
<p align="center">
|
|
44
|
+
Hopper provides a secure, open-source registry where every component is verified against malware and continuously remediated for vulnerabilities across all versions. In simple terms, Hopper removes the need to manage software supply chain risk altogether.
|
|
45
|
+
</p>
|
|
46
|
+
<p align="center">
|
|
47
|
+
<a
|
|
48
|
+
href="https://hopper.security/?utm_source=axios&utm_medium=readme_sponsorlist&utm_campaign=sponsorship"
|
|
49
|
+
target="_blank"
|
|
50
|
+
><b>hopper.security</b></a
|
|
51
|
+
>
|
|
52
|
+
</p>
|
|
53
|
+
</td>
|
|
54
|
+
</tr>
|
|
55
|
+
</table>
|
|
56
|
+
<table align="center">
|
|
57
|
+
<tr>
|
|
58
|
+
<td align="center" width="50%">
|
|
59
|
+
<a
|
|
60
|
+
href="https://opencollective.com/axios/contribute"
|
|
61
|
+
target="_blank"
|
|
62
|
+
>π Become a sponsor</a
|
|
63
|
+
>
|
|
64
|
+
</td>
|
|
65
|
+
<td align="center" width="50%">
|
|
66
|
+
<a
|
|
67
|
+
href="https://opencollective.com/axios/contribute"
|
|
68
|
+
target="_blank"
|
|
69
|
+
>π Become a sponsor</a
|
|
70
|
+
>
|
|
71
|
+
</td>
|
|
72
|
+
</tr>
|
|
73
|
+
</table>
|
|
74
|
+
<h3 align="center">π₯ Gold sponsors <br /></h3>
|
|
75
|
+
<table align="center" width="100%">
|
|
76
|
+
<tr width="33.333333333333336%">
|
|
77
|
+
<td align="center" width="33.333333333333336%">
|
|
78
|
+
<a
|
|
79
|
+
href="https://www.principal.com/about-us?utm_source=axios&utm_medium=sponsorlist&utm_campaign=sponsorship"
|
|
80
|
+
style="padding: 10px; display: inline-block"
|
|
81
|
+
target="_blank"
|
|
82
|
+
>
|
|
83
|
+
<img
|
|
84
|
+
width="90px"
|
|
85
|
+
height="90px"
|
|
86
|
+
src="https://images.opencollective.com/principal/431e690/logo.png"
|
|
87
|
+
alt="Principal Financial Group"
|
|
88
|
+
/>
|
|
89
|
+
</a>
|
|
90
|
+
<p
|
|
91
|
+
align="center"
|
|
92
|
+
>
|
|
93
|
+
Free tools to help with your financial planning needs!
|
|
94
|
+
</p>
|
|
95
|
+
<p align="center">
|
|
96
|
+
<a
|
|
97
|
+
href="https://www.principal.com/about-us?utm_source=axios&utm_medium=readme_sponsorlist&utm_campaign=sponsorship"
|
|
98
|
+
target="_blank"
|
|
99
|
+
><b>principal.com</b></a
|
|
100
|
+
>
|
|
101
|
+
</p>
|
|
102
|
+
</td>
|
|
103
|
+
<td align="center" width="33.333333333333336%">
|
|
104
|
+
<a
|
|
105
|
+
href="https://opensource.sap.com?utm_source=axios&utm_medium=sponsorlist&utm_campaign=sponsorship"
|
|
106
|
+
style="padding: 10px; display: inline-block"
|
|
107
|
+
target="_blank"
|
|
108
|
+
>
|
|
109
|
+
<img
|
|
110
|
+
width="90px"
|
|
111
|
+
height="90px"
|
|
112
|
+
src="https://avatars.githubusercontent.com/u/2531208?s=200&v=4"
|
|
113
|
+
alt="SAP"
|
|
114
|
+
/>
|
|
115
|
+
</a>
|
|
116
|
+
<p
|
|
117
|
+
align="center"
|
|
118
|
+
title="SAP SE, a global software company, is one of the largest vendors of ERP and other enterprise applications."
|
|
119
|
+
>
|
|
120
|
+
BSAP SE, a global software company, is one of the largest vendors of ERP and other enterprise applications.
|
|
121
|
+
</p>
|
|
122
|
+
<p align="center">
|
|
123
|
+
<a
|
|
124
|
+
href="https://opensource.sap.com?utm_source=axios&utm_medium=readme_sponsorlist&utm_campaign=sponsorship"
|
|
125
|
+
target="_blank"
|
|
126
|
+
><b>opensource.sap.com</b></a
|
|
127
|
+
>
|
|
128
|
+
</p>
|
|
129
|
+
</td>
|
|
130
|
+
<td align="center" width="33.333333333333336%">
|
|
131
|
+
<a
|
|
132
|
+
href="https://www.descope.com/?utm_source=axios&utm_medium=referral&utm_campaign=axios-oss-sponsorship"
|
|
133
|
+
style="padding: 10px; display: inline-block"
|
|
134
|
+
target="_blank"
|
|
135
|
+
>
|
|
136
|
+
<img
|
|
137
|
+
width="90px"
|
|
138
|
+
height="90px"
|
|
139
|
+
src="https://images.opencollective.com/descope/b53243e/logo.png"
|
|
140
|
+
alt="Descope"
|
|
141
|
+
/>
|
|
142
|
+
</a>
|
|
143
|
+
<p
|
|
144
|
+
align="center"
|
|
145
|
+
title="Hi, we're Descope! We are building something in the authentication space for app developers and canβt wait to place it in your hands."
|
|
146
|
+
>
|
|
147
|
+
Reduce user friction, prevent account takeover, and get a 360Β° view of your customer and agentic identities with the Descope External IAM platform.
|
|
148
|
+
</p>
|
|
149
|
+
<p align="center">
|
|
150
|
+
<a
|
|
151
|
+
href="https://www.descope.com/?utm_source=axios&utm_medium=referral&utm_campaign=axios-oss-sponsorship"
|
|
152
|
+
target="_blank"
|
|
153
|
+
><b>descope.com</b></a
|
|
154
|
+
>
|
|
155
|
+
</p>
|
|
156
|
+
</td>
|
|
157
|
+
</tr>
|
|
158
|
+
<tr width="33.333333333333336%">
|
|
159
|
+
<td align="center" width="33.333333333333336%">
|
|
160
|
+
<a
|
|
161
|
+
href="https://stytch.com/"
|
|
162
|
+
style="padding: 10px; display: inline-block"
|
|
163
|
+
target="_blank"
|
|
164
|
+
>
|
|
165
|
+
<img
|
|
166
|
+
width="90px"
|
|
167
|
+
height="90px"
|
|
168
|
+
src="https://images.opencollective.com/stytch/f84ce43/logo/256.png?height=256"
|
|
169
|
+
alt="Stytch"
|
|
170
|
+
/>
|
|
171
|
+
</a>
|
|
172
|
+
<p
|
|
173
|
+
align="center"
|
|
174
|
+
>
|
|
175
|
+
The identity platform for humans & AI agents
|
|
176
|
+
</p>
|
|
177
|
+
<p align="center">
|
|
178
|
+
<a
|
|
179
|
+
href="https://stytch.com"
|
|
180
|
+
target="_blank"
|
|
181
|
+
><b>stytch.com</b></a
|
|
182
|
+
>
|
|
183
|
+
</p>
|
|
184
|
+
</td>
|
|
185
|
+
<td align="center" width="33.333333333333336%">
|
|
186
|
+
<a
|
|
187
|
+
href="https://rxdb.info/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship&utm_content=logo"
|
|
188
|
+
style="padding: 10px; display: inline-block"
|
|
189
|
+
target="_blank"
|
|
190
|
+
>
|
|
191
|
+
<img
|
|
192
|
+
width="90px"
|
|
193
|
+
height="90px"
|
|
194
|
+
src="https://rxdb.info/files/logo/logo_text_white.svg"
|
|
195
|
+
alt="RxDB"
|
|
196
|
+
/>
|
|
197
|
+
</a>
|
|
198
|
+
<p
|
|
199
|
+
align="center"
|
|
200
|
+
>
|
|
201
|
+
RxDB is a NoSQL database for JavaScript that runs directly in your app.
|
|
202
|
+
</p>
|
|
203
|
+
<p align="center">
|
|
204
|
+
<a
|
|
205
|
+
href="https://rxdb.info/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship&utm_content=logo"
|
|
206
|
+
target="_blank"
|
|
207
|
+
><b>rxdb.info</b></a
|
|
208
|
+
>
|
|
209
|
+
</p>
|
|
210
|
+
</td>
|
|
211
|
+
<td align="center" width="33.333333333333336%">
|
|
212
|
+
<a
|
|
213
|
+
href="https://poprey.com/?utm_source=axios&utm_medium=sponsorlist&utm_campaign=sponsorship"
|
|
214
|
+
style="padding: 10px; display: inline-block"
|
|
215
|
+
target="_blank"
|
|
216
|
+
>
|
|
217
|
+
<img
|
|
218
|
+
width="70px"
|
|
219
|
+
height="70px"
|
|
220
|
+
src="https://images.opencollective.com/instagram-likes/2a72a03/avatar.png"
|
|
221
|
+
alt="Poprey"
|
|
222
|
+
/>
|
|
223
|
+
</a>
|
|
224
|
+
<p align="center">
|
|
225
|
+
Buy Instagram Likes
|
|
226
|
+
</p>
|
|
227
|
+
<p align="center">
|
|
228
|
+
<a
|
|
229
|
+
href="https://poprey.com/?utm_source=axios&utm_medium=readme_sponsorlist&utm_campaign=sponsorship"
|
|
230
|
+
target="_blank"
|
|
231
|
+
><b>poprey.com</b></a
|
|
232
|
+
>
|
|
233
|
+
</p>
|
|
234
|
+
</td>
|
|
235
|
+
</tr>
|
|
236
|
+
<tr width="33.333333333333336%">
|
|
237
|
+
<td align="center" width="33.333333333333336%">
|
|
238
|
+
<a
|
|
239
|
+
href="https://buzzoid.com/buy-instagram-followers/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
240
|
+
style="padding: 10px; display: inline-block"
|
|
241
|
+
target="_blank"
|
|
242
|
+
>
|
|
243
|
+
<img
|
|
244
|
+
width="71px"
|
|
245
|
+
height="70px"
|
|
246
|
+
src="https://images.opencollective.com/buzzoid-buy-instagram-followers/56a09fe/logo.png"
|
|
247
|
+
alt="Buzzoid - Buy Instagram Followers"
|
|
248
|
+
/>
|
|
249
|
+
</a>
|
|
250
|
+
<p
|
|
251
|
+
align="center"
|
|
252
|
+
>
|
|
253
|
+
At Buzzoid, you can buy Instagram followers quickly, safely, and easily with just a few clicks. Rated world's #1 IG service since 2012.
|
|
254
|
+
</p>
|
|
255
|
+
<p align="center">
|
|
256
|
+
<a
|
|
257
|
+
href="https://buzzoid.com/buy-instagram-followers/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
258
|
+
target="_blank"
|
|
259
|
+
><b>buzzoid.com</b></a
|
|
260
|
+
>
|
|
261
|
+
</p>
|
|
262
|
+
</td>
|
|
263
|
+
<td align="center" width="33.333333333333336%">
|
|
264
|
+
<a
|
|
265
|
+
href="https://twicsy.com/buy-instagram-followers/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
266
|
+
style="padding: 10px; display: inline-block"
|
|
267
|
+
target="_blank"
|
|
268
|
+
>
|
|
269
|
+
<img
|
|
270
|
+
width="71px"
|
|
271
|
+
height="70px"
|
|
272
|
+
src="https://images.opencollective.com/buy-instagram-followers-twicsy/b4c5d7f/logo/256.png?height=256"
|
|
273
|
+
alt="Buy Instagram Followers Twicsy"
|
|
274
|
+
/>
|
|
275
|
+
</a>
|
|
276
|
+
<p
|
|
277
|
+
align="center"
|
|
278
|
+
>
|
|
279
|
+
Buy real Instagram followers from Twicsy. Twicsy has been voted the best site to buy followers from the likes of US Magazine.
|
|
280
|
+
</p>
|
|
281
|
+
<p align="center">
|
|
282
|
+
<a
|
|
283
|
+
href="https://twicsy.com/buy-instagram-followers/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
284
|
+
target="_blank"
|
|
285
|
+
><b>twicsy.com</b></a
|
|
286
|
+
>
|
|
287
|
+
</p>
|
|
288
|
+
</td>
|
|
289
|
+
<td align="center" width="33.333333333333336%">
|
|
290
|
+
<a
|
|
291
|
+
href="https://opencollective.com/axios/contribute"
|
|
292
|
+
target="_blank"
|
|
293
|
+
>π Become a sponsor</a
|
|
294
|
+
>
|
|
295
|
+
</td>
|
|
296
|
+
</tr>
|
|
297
|
+
</table>
|
|
298
|
+
|
|
16
299
|
|
|
17
300
|
<!--<div>marker</div>-->
|
|
18
301
|
|
|
19
302
|
<br><br>
|
|
20
303
|
|
|
21
304
|
<div align="center">
|
|
22
|
-
<a href="https://axios
|
|
305
|
+
<a href="https://axios.rest"><img src="https://axios.rest/logo.svg" alt="Axios" /></a><br>
|
|
23
306
|
</div>
|
|
24
307
|
|
|
25
308
|
<p align="center">Promise based HTTP client for the browser and node.js</p>
|
|
26
309
|
|
|
27
310
|
<p align="center">
|
|
28
|
-
<a href="https://axios
|
|
29
|
-
<a href="https://axios
|
|
311
|
+
<a href="https://axios.rest/"><b>Website</b></a> β’
|
|
312
|
+
<a href="https://axios.rest/pages/getting-started/first-steps.html"><b>Documentation</b></a>
|
|
30
313
|
</p>
|
|
31
314
|
|
|
32
315
|
<div align="center">
|
|
@@ -41,7 +324,6 @@
|
|
|
41
324
|
[](https://npm-stat.com/charts.html?package=axios)
|
|
42
325
|
[](https://gitter.im/mzabriskie/axios)
|
|
43
326
|
[](https://www.codetriage.com/axios/axios)
|
|
44
|
-
[](https://snyk.io/test/npm/axios)
|
|
45
327
|
[](CONTRIBUTORS.md)
|
|
46
328
|
|
|
47
329
|
</div>
|
|
@@ -87,7 +369,7 @@
|
|
|
87
369
|
- [π₯ Fetch adapter](#-fetch-adapter)
|
|
88
370
|
- [π₯ Custom fetch](#-custom-fetch)
|
|
89
371
|
- [π₯ Using with Tauri](#-using-with-tauri)
|
|
90
|
-
- [π₯ Using with SvelteKit](#-using-with-sveltekit
|
|
372
|
+
- [π₯ Using with SvelteKit](#-using-with-sveltekit)
|
|
91
373
|
- [π₯ HTTP2](#-http2)
|
|
92
374
|
- [Semver](#semver)
|
|
93
375
|
- [Promises](#promises)
|
|
@@ -216,6 +498,7 @@ axios
|
|
|
216
498
|
params: {
|
|
217
499
|
ID: 12345,
|
|
218
500
|
},
|
|
501
|
+
timeout: 5000, // 5 seconds β see "Handling Timeouts" below for matching error handling
|
|
219
502
|
})
|
|
220
503
|
.then(function (response) {
|
|
221
504
|
console.log(response);
|
|
@@ -230,14 +513,25 @@ axios
|
|
|
230
513
|
// Want to use async/await? Add the `async` keyword to your outer function/method.
|
|
231
514
|
async function getUser() {
|
|
232
515
|
try {
|
|
233
|
-
|
|
234
|
-
|
|
516
|
+
// Example: GET request with query parameters
|
|
517
|
+
const response = await axios.get('/user', {
|
|
518
|
+
params: {
|
|
519
|
+
ID: 12345
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
// Using the `params` option improves readability and automatically formats query strings
|
|
524
|
+
|
|
525
|
+
console.log(response);
|
|
235
526
|
} catch (error) {
|
|
236
527
|
console.error(error);
|
|
237
528
|
}
|
|
238
529
|
}
|
|
239
530
|
```
|
|
240
531
|
|
|
532
|
+
> **Note**: Set a `timeout` in production β without one, a stalled request can hang
|
|
533
|
+
> indefinitely. See [Handling Timeouts](#handling-timeouts) for the matching error handling.
|
|
534
|
+
|
|
241
535
|
> **Note**: `async/await` is part of ECMAScript 2017 and is not supported in Internet
|
|
242
536
|
> Explorer and older browsers, so use with caution.
|
|
243
537
|
|
|
@@ -426,6 +720,27 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
426
720
|
return data;
|
|
427
721
|
}],
|
|
428
722
|
|
|
723
|
+
// `parseReviver` is an optional function that will be passed as the
|
|
724
|
+
// second argument (reviver) to JSON.parse()
|
|
725
|
+
parseReviver: function (key, value, context) {
|
|
726
|
+
// In modern environments, context.source provides the raw JSON string
|
|
727
|
+
// allowing for precision-safe parsing of BigInt
|
|
728
|
+
if (typeof value === 'number' && context?.source) {
|
|
729
|
+
const isInteger = Number.isInteger(value);
|
|
730
|
+
const isUnsafe = !Number.isSafeInteger(value);
|
|
731
|
+
const isValidIntegerString = /^-?\d+$/.test(context.source);
|
|
732
|
+
|
|
733
|
+
if (isInteger && isUnsafe && isValidIntegerString) {
|
|
734
|
+
try {
|
|
735
|
+
return BigInt(context.source);
|
|
736
|
+
} catch {
|
|
737
|
+
// Fallback: return original value if parsing fails
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
return value;
|
|
742
|
+
},
|
|
743
|
+
|
|
429
744
|
// `headers` are custom headers to be sent
|
|
430
745
|
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
|
431
746
|
|
|
@@ -463,6 +778,11 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
463
778
|
firstName: 'Fred'
|
|
464
779
|
},
|
|
465
780
|
|
|
781
|
+
// `formDataHeaderPolicy` controls how node.js FormData#getHeaders() is copied.
|
|
782
|
+
// 'legacy' (default) copies all returned headers for v1 compatibility.
|
|
783
|
+
// 'content-only' copies only Content-Type and Content-Length.
|
|
784
|
+
formDataHeaderPolicy: 'legacy',
|
|
785
|
+
|
|
466
786
|
// syntax alternative to send data into the body
|
|
467
787
|
// method post
|
|
468
788
|
// only the value is sent, not the key
|
|
@@ -557,6 +877,10 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
557
877
|
// `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed
|
|
558
878
|
maxBodyLength: 2000,
|
|
559
879
|
|
|
880
|
+
// `redact` masks matching config keys when AxiosError#toJSON() is called.
|
|
881
|
+
// Matching is case-insensitive and recursive. It does not change the request.
|
|
882
|
+
redact: ['authorization', 'password'],
|
|
883
|
+
|
|
560
884
|
// `validateStatus` defines whether to resolve or reject the promise for a given
|
|
561
885
|
// HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
|
|
562
886
|
// or `undefined`), the promise will be resolved; otherwise, the promise will be
|
|
@@ -636,9 +960,24 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
636
960
|
// Use `false` to disable proxies, ignoring environment variables.
|
|
637
961
|
// `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
|
|
638
962
|
// supplies credentials.
|
|
639
|
-
//
|
|
640
|
-
// `Proxy-Authorization`
|
|
963
|
+
// For `http://` targets, axios sends the request to the proxy in
|
|
964
|
+
// forward-proxy mode and stamps `Proxy-Authorization` onto the request
|
|
965
|
+
// headers (overwriting any user-supplied `Proxy-Authorization` header).
|
|
966
|
+
// For `https://` targets, axios establishes a CONNECT tunnel through the
|
|
967
|
+
// proxy and performs TLS end-to-end with the origin; `Proxy-Authorization`
|
|
968
|
+
// is sent on the CONNECT request only, never on the wrapped TLS request,
|
|
969
|
+
// so the proxy never sees the URL, headers, or body. Supply a custom
|
|
970
|
+
// `httpsAgent` to opt out of automatic CONNECT tunneling.
|
|
641
971
|
// If the proxy server uses HTTPS, then you must set the protocol to `https`.
|
|
972
|
+
// A user-supplied `Host` header in `headers` is preserved when forwarding
|
|
973
|
+
// through a proxy (case-insensitive match on `host`/`Host`/`HOST`); this
|
|
974
|
+
// lets you target a virtual host that differs from the request URL β for
|
|
975
|
+
// example, hitting `127.0.0.1:4000` while having the proxy treat the
|
|
976
|
+
// request as `example.com`. If no `Host` header is supplied, axios
|
|
977
|
+
// defaults it to the request URL's `hostname:port` as before. The Host
|
|
978
|
+
// header is only set in forward-proxy mode (HTTP targets); for HTTPS
|
|
979
|
+
// tunneling the Host header is sent inside the TLS connection, not seen
|
|
980
|
+
// by the proxy.
|
|
642
981
|
proxy: {
|
|
643
982
|
protocol: 'https',
|
|
644
983
|
host: '127.0.0.1',
|
|
@@ -715,6 +1054,25 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
715
1054
|
}
|
|
716
1055
|
```
|
|
717
1056
|
|
|
1057
|
+
### Strict RFC 3986 percent-encoding for query params
|
|
1058
|
+
|
|
1059
|
+
By default, axios decodes `%3A`, `%24`, `%2C` and `%20` back to `:`, `$`, `,` and `+` for readability (the `+` follows the `application/x-www-form-urlencoded` convention for spaces in query strings). These characters are valid in a query component under [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986#section-3.4), so the default output is correct, but some backends require strict percent-encoding and reject the readable form.
|
|
1060
|
+
|
|
1061
|
+
Override the default encoder via `paramsSerializer.encode`:
|
|
1062
|
+
|
|
1063
|
+
```js
|
|
1064
|
+
// Per-request: emit strict RFC 3986 percent-encoding for query values
|
|
1065
|
+
axios.get('/foo', {
|
|
1066
|
+
params: { filter: JSON.stringify({ startedAt: '2026-01-23' }) },
|
|
1067
|
+
paramsSerializer: { encode: encodeURIComponent }
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
// Or set it on the instance defaults
|
|
1071
|
+
const client = axios.create({
|
|
1072
|
+
paramsSerializer: { encode: encodeURIComponent }
|
|
1073
|
+
});
|
|
1074
|
+
```
|
|
1075
|
+
|
|
718
1076
|
## π₯ HTTP/2 Support
|
|
719
1077
|
|
|
720
1078
|
Axios has experimental HTTP/2 support available via the Node.js HTTP adapter.
|
|
@@ -857,7 +1215,7 @@ const instance = axios.create();
|
|
|
857
1215
|
const myInterceptor = instance.interceptors.request.use(function () {
|
|
858
1216
|
/*...*/
|
|
859
1217
|
});
|
|
860
|
-
|
|
1218
|
+
instance.interceptors.request.eject(myInterceptor);
|
|
861
1219
|
```
|
|
862
1220
|
|
|
863
1221
|
You can also clear all interceptors for requests or responses.
|
|
@@ -1046,6 +1404,17 @@ axios.get('/user/12345').catch(function (error) {
|
|
|
1046
1404
|
});
|
|
1047
1405
|
```
|
|
1048
1406
|
|
|
1407
|
+
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.
|
|
1408
|
+
|
|
1409
|
+
```js
|
|
1410
|
+
axios.get('/user/12345', {
|
|
1411
|
+
headers: { Authorization: 'Bearer token' },
|
|
1412
|
+
redact: ['authorization']
|
|
1413
|
+
}).catch(function (error) {
|
|
1414
|
+
console.log(error.toJSON().config.headers.Authorization); // [REDACTED ****]
|
|
1415
|
+
});
|
|
1416
|
+
```
|
|
1417
|
+
|
|
1049
1418
|
## Handling Timeouts
|
|
1050
1419
|
|
|
1051
1420
|
```js
|
|
@@ -1287,6 +1656,8 @@ form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
|
|
1287
1656
|
axios.post('https://example.com', form);
|
|
1288
1657
|
```
|
|
1289
1658
|
|
|
1659
|
+
In node.js, when a `FormData` object provides `getHeaders()`, axios copies all returned headers by default for v1 compatibility. If the `FormData` object is custom or not fully trusted, set `formDataHeaderPolicy: 'content-only'` to copy only `Content-Type` and `Content-Length`, and set any other request headers explicitly with the request `headers` config.
|
|
1660
|
+
|
|
1290
1661
|
### π Automatic serialization to FormData
|
|
1291
1662
|
|
|
1292
1663
|
Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData object if the request `Content-Type`
|