axios 1.18.0 → 1.19.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 +32 -0
- package/README.md +192 -23
- package/dist/axios.js +410 -101
- package/dist/axios.min.js +3 -3
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +484 -119
- package/dist/esm/axios.js +484 -119
- package/dist/esm/axios.min.js +2 -2
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +589 -139
- package/index.d.cts +114 -74
- package/index.d.ts +112 -68
- package/lib/adapters/adapters.js +1 -1
- package/lib/adapters/fetch.js +27 -12
- package/lib/adapters/http.js +95 -34
- package/lib/adapters/xhr.js +1 -0
- package/lib/core/Axios.js +24 -6
- package/lib/core/AxiosError.js +46 -3
- package/lib/core/AxiosHeaders.js +124 -1
- package/lib/core/buildFullPath.js +45 -7
- package/lib/core/mergeConfig.js +19 -3
- package/lib/core/setFormDataHeaders.js +27 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/AxiosURLSearchParams.js +1 -3
- package/lib/helpers/HttpStatusCode.js +1 -0
- package/lib/helpers/buildURL.js +1 -0
- package/lib/helpers/combineURLs.js +11 -3
- package/lib/helpers/composeSignals.js +12 -1
- package/lib/helpers/cookies.js +5 -1
- package/lib/helpers/estimateDataURLDecodedBytes.js +115 -54
- package/lib/helpers/formDataToJSON.js +11 -5
- package/lib/helpers/fromDataURI.js +4 -2
- package/lib/helpers/parseHeaders.js +5 -3
- package/lib/helpers/progressEventReducer.js +3 -3
- package/lib/helpers/resolveConfig.js +10 -19
- package/lib/helpers/shouldBypassProxy.js +120 -1
- package/lib/helpers/toFormData.js +8 -1
- package/lib/helpers/validator.js +1 -1
- package/lib/platform/node/classes/Buffer.js +11 -0
- package/lib/utils.js +17 -5
- package/package.json +22 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.18.0 — June 13, 2026
|
|
4
|
+
|
|
5
|
+
This release hardens redirect and URL handling, improves the validateStatus configuration semantics, and includes updates to documentation, dependencies, and release metadata.
|
|
6
|
+
|
|
7
|
+
## 🔒 Security Fixes
|
|
8
|
+
|
|
9
|
+
* **Redirect Header Safety:** Added Node HTTP adapter support for stripping caller-specified sensitive headers on cross-origin redirects, helping prevent custom auth headers such as API keys from leaking to another origin. (__#10892__)
|
|
10
|
+
|
|
11
|
+
* **URL And Request Hardening:** Rejects malformed `http:` and `https:` URLs that omit `//` with `ERR_INVALID_URL`, while tightening prototype-pollution-safe config reads, stream size limits, FormData depth handling, data URL sizing, and local `NO_PROXY` matching. (__#11000__)
|
|
12
|
+
|
|
13
|
+
## 🐛 Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **Status Validation:** Added `transitional.validateStatusUndefinedResolves` so applications can opt in to treating `validateStatus: undefined` like the option was omitted, while `validateStatus: null` remains the explicit way to accept every status. (__#10899__)
|
|
16
|
+
|
|
17
|
+
## 🔧 Maintenance & Chores
|
|
18
|
+
|
|
19
|
+
* **Documentation:** Published the v1.17.0 release notes, fixed a changelog typo, clarified the package update PR policy, and marked the `proxy` request config as Node.js-only in the advanced docs. (__#10984__, __#10988__, __#10992__, __#10995__)
|
|
20
|
+
|
|
21
|
+
* **Dependencies:** Bumped `@babel/core`, `@babel/preset-env`, `@commitlint/cli`, `@commitlint/config-conventional`, `@rollup/plugin-babel`, `@rollup/plugin-commonjs`, `@vitest/browser`, `@vitest/browser-playwright`, `eslint`, `lint-staged`, `rollup`, `vitest`, and `actions/checkout`. (__#10989__, __#10996__, __#10997__)
|
|
22
|
+
|
|
23
|
+
* **Release Metadata:** Prepared the 1.18.0 release by updating package metadata and the runtime `VERSION` value. (__#11003__)
|
|
24
|
+
|
|
25
|
+
## 🌟 New Contributors
|
|
26
|
+
|
|
27
|
+
We are thrilled to welcome our new contributors. Thank you for helping improve axios:
|
|
28
|
+
|
|
29
|
+
* __@drori12__ (__#10984__)
|
|
30
|
+
* __@eyupcanakman__ (__#10899__)
|
|
31
|
+
* __@Adi-Beker__ (__#10995__)
|
|
32
|
+
|
|
33
|
+
[Full Changelog](https://github.com/axios/axios/compare/v1.17.0...v1.18.0)
|
|
34
|
+
|
|
3
35
|
## v1.17.0 — June 1, 2026
|
|
4
36
|
|
|
5
37
|
This release adds Node HTTP zstd decompression, hardens config and release workflows, and fixes authentication, header, proxy, and type-handling regressions.
|
package/README.md
CHANGED
|
@@ -296,9 +296,69 @@
|
|
|
296
296
|
</p>
|
|
297
297
|
</td>
|
|
298
298
|
</tr>
|
|
299
|
+
<tr width="33.333333333333336%">
|
|
300
|
+
<td align="center" width="33.333333333333336%">
|
|
301
|
+
<a
|
|
302
|
+
href="https://www.jbo88b.com/vn/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
303
|
+
style="padding: 10px; display: inline-block"
|
|
304
|
+
target="_blank"
|
|
305
|
+
>
|
|
306
|
+
<img
|
|
307
|
+
width="71px"
|
|
308
|
+
height="70px"
|
|
309
|
+
src="https://images.opencollective.com/jbo-vietnam/3fc6159/avatar.png"
|
|
310
|
+
alt="JBO Vietnam"
|
|
311
|
+
/>
|
|
312
|
+
</a>
|
|
313
|
+
<p
|
|
314
|
+
align="center"
|
|
315
|
+
>
|
|
316
|
+
JBO Vietnam is a prominent online entertainment brand in Vietnam, offering sports betting, esports, online casino games, and a wide range of other exciting games.
|
|
317
|
+
</p>
|
|
318
|
+
<p align="center">
|
|
319
|
+
<a
|
|
320
|
+
href="https://www.jbo88b.com/vn/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
321
|
+
target="_blank"
|
|
322
|
+
><b>jbo88b.com</b></a
|
|
323
|
+
>
|
|
324
|
+
</p>
|
|
325
|
+
</td>
|
|
326
|
+
<td align="center" width="33.333333333333336%">
|
|
327
|
+
<a
|
|
328
|
+
href="https://www.jbo579.com/th/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
329
|
+
style="padding: 10px; display: inline-block"
|
|
330
|
+
target="_blank"
|
|
331
|
+
>
|
|
332
|
+
<img
|
|
333
|
+
width="71px"
|
|
334
|
+
height="70px"
|
|
335
|
+
src="https://images.opencollective.com/jbo-thailand/d17e84f/avatar.png"
|
|
336
|
+
alt="JBO Thailand"
|
|
337
|
+
/>
|
|
338
|
+
</a>
|
|
339
|
+
<p
|
|
340
|
+
align="center"
|
|
341
|
+
>
|
|
342
|
+
JBO Thailand is a prominent online entertainment brand in Thailand, offering sports betting, esports, online casino games, and a wide range of other exciting games.
|
|
343
|
+
</p>
|
|
344
|
+
<p align="center">
|
|
345
|
+
<a
|
|
346
|
+
href="https://www.jbo579.com/th/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
347
|
+
target="_blank"
|
|
348
|
+
><b>jbo88b.com</b></a
|
|
349
|
+
>
|
|
350
|
+
</p>
|
|
351
|
+
</td>
|
|
352
|
+
<td align="center" width="33.333333333333336%">
|
|
353
|
+
<a
|
|
354
|
+
href="https://opencollective.com/axios/contribute"
|
|
355
|
+
target="_blank"
|
|
356
|
+
>💜 Become a sponsor</a
|
|
357
|
+
>
|
|
358
|
+
</td>
|
|
359
|
+
</tr>
|
|
299
360
|
</table>
|
|
300
361
|
|
|
301
|
-
|
|
302
362
|
<!--<div>marker</div>-->
|
|
303
363
|
|
|
304
364
|
<br><br>
|
|
@@ -430,6 +490,12 @@ Using bun:
|
|
|
430
490
|
$ bun add axios
|
|
431
491
|
```
|
|
432
492
|
|
|
493
|
+
Using Deno:
|
|
494
|
+
|
|
495
|
+
```bash
|
|
496
|
+
$ deno add axios
|
|
497
|
+
```
|
|
498
|
+
|
|
433
499
|
Once the package is installed, import it with `import` or `require`:
|
|
434
500
|
|
|
435
501
|
```js
|
|
@@ -513,16 +579,16 @@ axios
|
|
|
513
579
|
// Want to use async/await? Add the `async` keyword to your outer function/method.
|
|
514
580
|
async function getUser() {
|
|
515
581
|
try {
|
|
516
|
-
// Example: GET request with query parameters
|
|
517
|
-
const response = await axios.get('/user', {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
});
|
|
582
|
+
// Example: GET request with query parameters
|
|
583
|
+
const response = await axios.get('/user', {
|
|
584
|
+
params: {
|
|
585
|
+
ID: 12345,
|
|
586
|
+
},
|
|
587
|
+
});
|
|
522
588
|
|
|
523
|
-
// Using the `params` option improves readability and automatically formats query strings
|
|
589
|
+
// Using the `params` option improves readability and automatically formats query strings
|
|
524
590
|
|
|
525
|
-
console.log(response);
|
|
591
|
+
console.log(response);
|
|
526
592
|
} catch (error) {
|
|
527
593
|
console.error(error);
|
|
528
594
|
}
|
|
@@ -694,6 +760,9 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
694
760
|
// Axios prepends `baseURL` to `url` unless `url` is absolute and `allowAbsoluteUrls` is set to true.
|
|
695
761
|
// It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
|
|
696
762
|
// to the methods of that instance.
|
|
763
|
+
// `baseURL` is not a security boundary. If `url` is attacker-controlled, validate it
|
|
764
|
+
// before passing it to axios. Relative URLs can contain `..` segments that resolve
|
|
765
|
+
// outside an intended path prefix after the final URL is parsed.
|
|
697
766
|
baseURL: 'https://some-domain.com/api/',
|
|
698
767
|
|
|
699
768
|
// `allowAbsoluteUrls` determines whether or not absolute URLs will override a configured `baseUrl`.
|
|
@@ -770,6 +839,8 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
770
839
|
|
|
771
840
|
// `data` is the data to be sent as the request body
|
|
772
841
|
// Only applicable for request methods 'PUT', 'POST', 'DELETE', and 'PATCH'
|
|
842
|
+
// `data` is request-specific: axios does not inherit or deep-merge it from defaults.
|
|
843
|
+
// To add shared body fields, use a request interceptor or transformRequest.
|
|
773
844
|
// When no `transformRequest` is set, it must be of one of the following types:
|
|
774
845
|
// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
|
|
775
846
|
// - Browser only: FormData, File, Blob
|
|
@@ -891,8 +962,11 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
891
962
|
redact: ['authorization', 'password'],
|
|
892
963
|
|
|
893
964
|
// `validateStatus` defines whether to resolve or reject the promise for a given
|
|
894
|
-
// HTTP response status code. If `validateStatus` returns `true`
|
|
895
|
-
//
|
|
965
|
+
// HTTP response status code. If `validateStatus` returns `true` or is set to
|
|
966
|
+
// `null`, Axios resolves the promise; otherwise, Axios rejects it.
|
|
967
|
+
// Explicit `validateStatus: undefined` resolves every status by default for
|
|
968
|
+
// backward compatibility. Set `transitional.validateStatusUndefinedResolves`
|
|
969
|
+
// to `false` to make explicit `undefined` behave as if this option was omitted.
|
|
896
970
|
validateStatus: function (status) {
|
|
897
971
|
return status >= 200 && status < 300; // default
|
|
898
972
|
},
|
|
@@ -902,9 +976,9 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
902
976
|
maxRedirects: 21, // default
|
|
903
977
|
|
|
904
978
|
// `sensitiveHeaders` (Node only option) lists custom secret-bearing headers
|
|
905
|
-
// to remove from cross-origin redirects. Matching is
|
|
906
|
-
// Same-origin redirects keep these headers. If
|
|
907
|
-
// option is not used.
|
|
979
|
+
// (such as `X-API-Key`) to remove from cross-origin redirects. Matching is
|
|
980
|
+
// case-insensitive. Same-origin redirects keep these headers. If
|
|
981
|
+
// `maxRedirects` is 0, this option is not used.
|
|
908
982
|
sensitiveHeaders: ['X-API-Key'],
|
|
909
983
|
|
|
910
984
|
// `beforeRedirect` defines a function that Axios calls before redirect.
|
|
@@ -966,6 +1040,12 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
966
1040
|
// for your proxy configuration, you can also define a `no_proxy` environment
|
|
967
1041
|
// variable as a comma-separated list of domains that should not be proxied.
|
|
968
1042
|
// Use `false` to disable proxies, ignoring environment variables.
|
|
1043
|
+
// On Node.js versions with native environment proxy support, axios defers
|
|
1044
|
+
// environment proxy handling to Node when the selected agent has `proxyEnv`
|
|
1045
|
+
// enabled, including processes started with `NODE_USE_ENV_PROXY=1`,
|
|
1046
|
+
// `--use-env-proxy`, or `NODE_OPTIONS=--use-env-proxy`. Custom agents without
|
|
1047
|
+
// `proxyEnv` continue to use axios environment proxy resolution. Explicit
|
|
1048
|
+
// `proxy` config is still handled by axios.
|
|
969
1049
|
// `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
|
|
970
1050
|
// supplies credentials.
|
|
971
1051
|
// For `http://` targets, axios sends the request to the proxy in
|
|
@@ -1042,6 +1122,11 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
1042
1122
|
// throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
|
|
1043
1123
|
clarifyTimeoutError: false,
|
|
1044
1124
|
|
|
1125
|
+
// keep explicit `validateStatus: undefined` resolving every response status
|
|
1126
|
+
// for backward compatibility. Set to false to make explicit undefined behave
|
|
1127
|
+
// as if validateStatus was omitted.
|
|
1128
|
+
validateStatusUndefinedResolves: true,
|
|
1129
|
+
|
|
1045
1130
|
// advertise `zstd` in the default Accept-Encoding header when the current
|
|
1046
1131
|
// Node.js runtime supports zstd decompression. Axios still decompresses
|
|
1047
1132
|
// zstd responses when support exists and `decompress` is true.
|
|
@@ -1072,6 +1157,15 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
1072
1157
|
}
|
|
1073
1158
|
```
|
|
1074
1159
|
|
|
1160
|
+
For custom secret-bearing headers in Node.js, list them in `sensitiveHeaders` so Axios removes them when following a redirect to another origin:
|
|
1161
|
+
|
|
1162
|
+
```js
|
|
1163
|
+
axios.get('https://api.example.com/users', {
|
|
1164
|
+
headers: { 'X-API-Key': 'secret' },
|
|
1165
|
+
sensitiveHeaders: ['X-API-Key'],
|
|
1166
|
+
});
|
|
1167
|
+
```
|
|
1168
|
+
|
|
1075
1169
|
### Strict RFC 3986 percent-encoding for query params
|
|
1076
1170
|
|
|
1077
1171
|
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.
|
|
@@ -1082,12 +1176,12 @@ Override the default encoder via `paramsSerializer.encode`:
|
|
|
1082
1176
|
// Per-request: emit strict RFC 3986 percent-encoding for query values
|
|
1083
1177
|
axios.get('/foo', {
|
|
1084
1178
|
params: { filter: JSON.stringify({ startedAt: '2026-01-23' }) },
|
|
1085
|
-
paramsSerializer: { encode: encodeURIComponent }
|
|
1179
|
+
paramsSerializer: { encode: encodeURIComponent },
|
|
1086
1180
|
});
|
|
1087
1181
|
|
|
1088
1182
|
// Or set it on the instance defaults
|
|
1089
1183
|
const client = axios.create({
|
|
1090
|
-
paramsSerializer: { encode: encodeURIComponent }
|
|
1184
|
+
paramsSerializer: { encode: encodeURIComponent },
|
|
1091
1185
|
});
|
|
1092
1186
|
```
|
|
1093
1187
|
|
|
@@ -1176,6 +1270,8 @@ instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
|
|
|
1176
1270
|
|
|
1177
1271
|
Axios merges config in this order: library defaults from [lib/defaults/index.js](https://github.com/axios/axios/blob/main/lib/defaults/index.js#L49), the instance `defaults` property, and the request `config` argument. Later values take precedence over earlier ones.
|
|
1178
1272
|
|
|
1273
|
+
Some options are request-specific and are only taken from the request `config`. `data` is one of those options: axios does not inherit or deep-merge request bodies from global or instance defaults. If every request needs shared body fields, add them with a request interceptor or `transformRequest`, and scope that logic carefully so sensitive values are not sent to the wrong endpoint.
|
|
1274
|
+
|
|
1179
1275
|
```js
|
|
1180
1276
|
// Create an instance using the config defaults provided by the library
|
|
1181
1277
|
// At this point the timeout config value is `0` as is the default for the library
|
|
@@ -1369,7 +1465,7 @@ These are the internal Axios error codes:
|
|
|
1369
1465
|
| ERR_INVALID_URL | Invalid URL provided for axios request. |
|
|
1370
1466
|
| ECONNABORTED | Typically indicates that the request has been timed out (unless `transitional.clarifyTimeoutError` is set) or aborted by the browser or its plugin. |
|
|
1371
1467
|
| ERR_CANCELED | The user explicitly canceled the request with an AbortSignal or CancelToken. |
|
|
1372
|
-
| ETIMEDOUT | Request timed out after exceeding the configured Axios timeout. Set `transitional.clarifyTimeoutError` to `true`; otherwise Axios throws a generic `ECONNABORTED` error.
|
|
1468
|
+
| ETIMEDOUT | Request timed out after exceeding the configured Axios timeout. Set `transitional.clarifyTimeoutError` to `true`; otherwise Axios throws a generic `ECONNABORTED` error. |
|
|
1373
1469
|
| ERR_NETWORK | Network-related issue. In the browser, this error can also be caused by a [CORS](https://developer.mozilla.org/ru/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. |
|
|
1374
1470
|
| ERR_FR_TOO_MANY_REDIRECTS | Request exceeded the configured maximum number of redirects. |
|
|
1375
1471
|
| ERR_BAD_RESPONSE | Response cannot be parsed properly or is in an unexpected format. Usually related to a response with `5xx` status code. |
|
|
@@ -1410,6 +1506,19 @@ axios.get('/user/12345', {
|
|
|
1410
1506
|
});
|
|
1411
1507
|
```
|
|
1412
1508
|
|
|
1509
|
+
By default, explicit `validateStatus: undefined` keeps legacy behavior and resolves every response status because `transitional.validateStatusUndefinedResolves` defaults to `true`. Set it to `false` to make explicit `validateStatus: undefined` behave like the option was omitted, so Axios uses the configured/default validator and rejects non-2xx responses by default.
|
|
1510
|
+
|
|
1511
|
+
`validateStatus: null` still accepts every response status. If you disable the transitional behavior and intentionally want all statuses to resolve, use `null` or `() => true`.
|
|
1512
|
+
|
|
1513
|
+
```js
|
|
1514
|
+
axios.get('/user/12345', {
|
|
1515
|
+
validateStatus: undefined,
|
|
1516
|
+
transitional: {
|
|
1517
|
+
validateStatusUndefinedResolves: false,
|
|
1518
|
+
},
|
|
1519
|
+
});
|
|
1520
|
+
```
|
|
1521
|
+
|
|
1413
1522
|
Use `toJSON` to get more information about the HTTP error.
|
|
1414
1523
|
|
|
1415
1524
|
```js
|
|
@@ -1421,12 +1530,14 @@ axios.get('/user/12345').catch(function (error) {
|
|
|
1421
1530
|
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.
|
|
1422
1531
|
|
|
1423
1532
|
```js
|
|
1424
|
-
axios
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1533
|
+
axios
|
|
1534
|
+
.get('/user/12345', {
|
|
1535
|
+
headers: { Authorization: 'Bearer token' },
|
|
1536
|
+
redact: ['authorization'],
|
|
1537
|
+
})
|
|
1538
|
+
.catch(function (error) {
|
|
1539
|
+
console.log(error.toJSON().config.headers.Authorization); // [REDACTED ****]
|
|
1540
|
+
});
|
|
1430
1541
|
```
|
|
1431
1542
|
|
|
1432
1543
|
## Handling timeouts
|
|
@@ -1536,11 +1647,44 @@ axios.get('/user/12345', {
|
|
|
1536
1647
|
cancel();
|
|
1537
1648
|
```
|
|
1538
1649
|
|
|
1650
|
+
`CancelToken` also exposes low-level helpers for legacy integrations:
|
|
1651
|
+
|
|
1652
|
+
```js
|
|
1653
|
+
const source = axios.CancelToken.source();
|
|
1654
|
+
|
|
1655
|
+
const listener = (cancel) => {
|
|
1656
|
+
console.log(cancel.message);
|
|
1657
|
+
};
|
|
1658
|
+
|
|
1659
|
+
source.token.subscribe(listener);
|
|
1660
|
+
|
|
1661
|
+
const signal = source.token.toAbortSignal();
|
|
1662
|
+
// Pass `signal` to APIs that accept AbortSignal.
|
|
1663
|
+
|
|
1664
|
+
source.cancel('Operation canceled by the user.');
|
|
1665
|
+
source.token.unsubscribe(listener);
|
|
1666
|
+
```
|
|
1667
|
+
|
|
1668
|
+
Canceled requests reject with `axios.CanceledError`. The legacy `axios.Cancel` export is an alias of `axios.CanceledError`, and cancellation errors include `__CANCEL__` for `axios.isCancel` compatibility.
|
|
1669
|
+
|
|
1539
1670
|
> Note: You can cancel several requests with the same cancel token or abort controller.
|
|
1540
1671
|
> If a cancellation token is already cancelled when an Axios request starts, Axios cancels the request immediately without making a real request.
|
|
1541
1672
|
|
|
1542
1673
|
> During the transition period, you can use both cancellation APIs, even for the same request:
|
|
1543
1674
|
|
|
1675
|
+
```js
|
|
1676
|
+
const controller = new AbortController();
|
|
1677
|
+
const source = axios.CancelToken.source();
|
|
1678
|
+
|
|
1679
|
+
axios.get('/user/12345', {
|
|
1680
|
+
cancelToken: source.token,
|
|
1681
|
+
signal: controller.signal,
|
|
1682
|
+
});
|
|
1683
|
+
|
|
1684
|
+
controller.abort();
|
|
1685
|
+
source.cancel('Operation canceled by the user.');
|
|
1686
|
+
```
|
|
1687
|
+
|
|
1544
1688
|
## Using `application/x-www-form-urlencoded` format
|
|
1545
1689
|
|
|
1546
1690
|
### URLSearchParams
|
|
@@ -1742,6 +1886,9 @@ FormData serializer supports additional options via `config.formSerializer: obje
|
|
|
1742
1886
|
input object exceeds this depth, an `AxiosError` with `code: 'ERR_FORM_DATA_DEPTH_EXCEEDED'` is
|
|
1743
1887
|
thrown instead of overflowing the call stack. This protects server applications from DoS
|
|
1744
1888
|
attacks via deeply nested payloads. Set to `Infinity` to disable the limit and restore pre-fix behaviour.
|
|
1889
|
+
- `Blob: typeof Blob` - Blob constructor used when converting ArrayBuffer-like values for spec-compliant
|
|
1890
|
+
`FormData`. Override it only for runtimes that provide a compatible `Blob` constructor under a
|
|
1891
|
+
different binding.
|
|
1745
1892
|
|
|
1746
1893
|
```js
|
|
1747
1894
|
// Raise the limit for a schema that genuinely nests deeper than 100 levels:
|
|
@@ -2068,6 +2215,7 @@ console.log(headers);
|
|
|
2068
2215
|
set(headerName, value: Axios, rewrite?: boolean);
|
|
2069
2216
|
set(headerName, value, rewrite?: (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean);
|
|
2070
2217
|
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean);
|
|
2218
|
+
set(headers?: Iterable<[string, AxiosHeaderValue]>, rewrite?: boolean);
|
|
2071
2219
|
```
|
|
2072
2220
|
|
|
2073
2221
|
The `rewrite` argument controls the overwriting behavior:
|
|
@@ -2080,6 +2228,19 @@ The option can also accept a user-defined function that determines whether to ov
|
|
|
2080
2228
|
|
|
2081
2229
|
Empty or whitespace-only header names are ignored.
|
|
2082
2230
|
|
|
2231
|
+
Iterable key/value pairs, such as a `Map`, are accepted:
|
|
2232
|
+
|
|
2233
|
+
```js
|
|
2234
|
+
const headers = new AxiosHeaders();
|
|
2235
|
+
|
|
2236
|
+
headers.set(
|
|
2237
|
+
new Map([
|
|
2238
|
+
['X-Trace-Id', 'abc123'],
|
|
2239
|
+
['Accept', 'application/json'],
|
|
2240
|
+
])
|
|
2241
|
+
);
|
|
2242
|
+
```
|
|
2243
|
+
|
|
2083
2244
|
Returns `this`.
|
|
2084
2245
|
|
|
2085
2246
|
### AxiosHeaders#get(header)
|
|
@@ -2200,6 +2361,14 @@ toJSON(asStrings?: false): Record<string, string | string[]>;
|
|
|
2200
2361
|
Resolves all internal header values into a new null prototype object.
|
|
2201
2362
|
Set `asStrings` to true to resolve arrays as a string containing all elements, separated by commas.
|
|
2202
2363
|
|
|
2364
|
+
### AxiosHeaders#toString()
|
|
2365
|
+
|
|
2366
|
+
```
|
|
2367
|
+
toString(): string;
|
|
2368
|
+
```
|
|
2369
|
+
|
|
2370
|
+
Returns the headers as a CRLF-free HTTP header block, one `name: value` pair per line.
|
|
2371
|
+
|
|
2203
2372
|
### AxiosHeaders.from(thing?)
|
|
2204
2373
|
|
|
2205
2374
|
```
|