Visitar URL original
chore(release): prepare release 1.18.1 (#11027) · axios/axios@a209bfb · GitHub
Skip to content

Commit a209bfb

Browse files
chore(release): prepare release 1.18.1 (#11027)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: jasonsaayman <4814473+jasonsaayman@users.noreply.github.com> Co-authored-by: Jason Saayman <jasonsaayman@gmail.com>
1 parent fa6a55e commit a209bfb

29 files changed

Lines changed: 607 additions & 272 deletions

‎PRE_RELEASE_DOCS.md‎

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,3 @@ Do not store raw diffs or line-number-only instructions here; prefer stable sect
1919
- **Notes:** Constraints, release-only wording, translation follow-up, etc.
2020

2121
## Unreleased
22-
23-
### Request data defaults clarification
24-
25-
- **Change:** Clarify that request `data` is request-specific and is not inherited or deep-merged from defaults.
26-
- **Source:** Documentation clarification for issue #5188 / PR #11020 review.
27-
- **Status:** Applied.
28-
- **Docs targets:** `README.md`; English, Spanish, French, and Chinese request config and config defaults pages.
29-
- **Required content:** Explain that `data` is only taken from the per-request config. Shared body fields should be added with a request interceptor or `transformRequest`, scoped carefully to avoid sending sensitive values to unintended endpoints.
30-
- **Examples:** None required.
31-
- **Notes:** English README/docs and translated docs pages have been updated directly.
32-
33-
### Runtime and type declaration hardening
34-
35-
- **Change:** Document the runtime edge-case fixes and public type declaration additions.
36-
- **Source:** `PRE_RELEASE_CHANGELOG.md` Bug Fixes, #10959.
37-
- **Status:** Pending.
38-
- **Docs targets:** `README.md` cancellation section; `README.md` `AxiosHeaders` section; `README.md` FormData serializer section; generated docs pages for cancellation, headers, and multipart/urlencoded form serialization; translated docs after English docs are finalized.
39-
- **Required content:** Note that `CancelToken.subscribe`, `CancelToken.unsubscribe`, `CancelToken.toAbortSignal`, `CanceledError` constructor/`__CANCEL__`, `AxiosHeaders#set(Iterable)`, `AxiosHeaders#toString()`, `SerializerOptions.maxDepth`, `SerializerOptions.Blob`, and `axios.Cancel` typings now match the runtime API. Release notes should also mention the cookie, data URI, form serialization, config validation, XHR cleanup, and Node HTTP adapter error-shape hardening.
40-
- **Examples:** Consider a short `CancelToken.toAbortSignal()` example and an `AxiosHeaders#set(new Map(...))` example if the docs section is updated.
41-
- **Notes:** Keep this as release-preparation tracking. Do not imply that `CancelToken` is no longer deprecated.
42-
43-
### Node native env proxy interaction
44-
45-
- **Change:** Document how the Node.js HTTP adapter interacts with Node native environment proxy handling.
46-
- **Source:** `PRE_RELEASE_CHANGELOG.md` Bug Fixes, #10942, closes #7299.
47-
- **Status:** Pending.
48-
- **Docs targets:** `README.md` proxy/request config sections; `docs/pages/advanced/request-config.md`; translated request-config docs after English docs are finalized.
49-
- **Required content:** Explain that axios normally resolves `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` itself for the Node.js HTTP adapter unless `config.proxy` is `false`. On Node.js versions with native HTTP proxy support, axios defers environment proxy handling to Node when the selected HTTP/HTTPS agent has `proxyEnv` enabled, including processes started with `NODE_USE_ENV_PROXY=1`, `--use-env-proxy`, or `NODE_OPTIONS=--use-env-proxy`. Custom agents without `proxyEnv` continue to use axios env proxy resolution. Explicit `config.proxy` remains handled by axios.
50-
- **Examples:** None required.
51-
- **Notes:** Keep the wording Node.js-only. Mention that this avoids double proxy rewriting while preserving existing custom-agent behavior.

‎README.md‎

Lines changed: 86 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@
298298
</tr>
299299
</table>
300300

301-
302301
<!--<div>marker</div>-->
303302

304303
<br><br>
@@ -519,16 +518,16 @@ axios
519518
// Want to use async/await? Add the `async` keyword to your outer function/method.
520519
async function getUser() {
521520
try {
522-
// Example: GET request with query parameters
523-
const response = await axios.get('/user', {
524-
params: {
525-
ID: 12345
526-
}
527-
});
521+
// Example: GET request with query parameters
522+
const response = await axios.get('/user', {
523+
params: {
524+
ID: 12345,
525+
},
526+
});
528527

529-
// Using the `params` option improves readability and automatically formats query strings
528+
// Using the `params` option improves readability and automatically formats query strings
530529

531-
console.log(response);
530+
console.log(response);
532531
} catch (error) {
533532
console.error(error);
534533
}
@@ -977,6 +976,12 @@ These config options are available for requests. Only `url` is required. Request
977976
// for your proxy configuration, you can also define a `no_proxy` environment
978977
// variable as a comma-separated list of domains that should not be proxied.
979978
// Use `false` to disable proxies, ignoring environment variables.
979+
// On Node.js versions with native environment proxy support, axios defers
980+
// environment proxy handling to Node when the selected agent has `proxyEnv`
981+
// enabled, including processes started with `NODE_USE_ENV_PROXY=1`,
982+
// `--use-env-proxy`, or `NODE_OPTIONS=--use-env-proxy`. Custom agents without
983+
// `proxyEnv` continue to use axios environment proxy resolution. Explicit
984+
// `proxy` config is still handled by axios.
980985
// `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
981986
// supplies credentials.
982987
// For `http://` targets, axios sends the request to the proxy in
@@ -1093,7 +1098,7 @@ For custom secret-bearing headers in Node.js, list them in `sensitiveHeaders` so
10931098
```js
10941099
axios.get('https://api.example.com/users', {
10951100
headers: { 'X-API-Key': 'secret' },
1096-
sensitiveHeaders: ['X-API-Key']
1101+
sensitiveHeaders: ['X-API-Key'],
10971102
});
10981103
```
10991104
@@ -1107,12 +1112,12 @@ Override the default encoder via `paramsSerializer.encode`:
11071112
// Per-request: emit strict RFC 3986 percent-encoding for query values
11081113
axios.get('/foo', {
11091114
params: { filter: JSON.stringify({ startedAt: '2026-01-23' }) },
1110-
paramsSerializer: { encode: encodeURIComponent }
1115+
paramsSerializer: { encode: encodeURIComponent },
11111116
});
11121117

11131118
// Or set it on the instance defaults
11141119
const client = axios.create({
1115-
paramsSerializer: { encode: encodeURIComponent }
1120+
paramsSerializer: { encode: encodeURIComponent },
11161121
});
11171122
```
11181123
@@ -1396,7 +1401,7 @@ These are the internal Axios error codes:
13961401
| ERR_INVALID_URL | Invalid URL provided for axios request. |
13971402
| ECONNABORTED | Typically indicates that the request has been timed out (unless `transitional.clarifyTimeoutError` is set) or aborted by the browser or its plugin. |
13981403
| ERR_CANCELED | The user explicitly canceled the request with an AbortSignal or CancelToken. |
1399-
| ETIMEDOUT | Request timed out after exceeding the configured Axios timeout. Set `transitional.clarifyTimeoutError` to `true`; otherwise Axios throws a generic `ECONNABORTED` error. |
1404+
| ETIMEDOUT | Request timed out after exceeding the configured Axios timeout. Set `transitional.clarifyTimeoutError` to `true`; otherwise Axios throws a generic `ECONNABORTED` error. |
14001405
| 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. |
14011406
| ERR_FR_TOO_MANY_REDIRECTS | Request exceeded the configured maximum number of redirects. |
14021407
| ERR_BAD_RESPONSE | Response cannot be parsed properly or is in an unexpected format. Usually related to a response with `5xx` status code. |
@@ -1445,8 +1450,8 @@ By default, explicit `validateStatus: undefined` keeps legacy behavior and resol
14451450
axios.get('/user/12345', {
14461451
validateStatus: undefined,
14471452
transitional: {
1448-
validateStatusUndefinedResolves: false
1449-
}
1453+
validateStatusUndefinedResolves: false,
1454+
},
14501455
});
14511456
```
14521457
@@ -1461,12 +1466,14 @@ axios.get('/user/12345').catch(function (error) {
14611466
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.
14621467
14631468
```js
1464-
axios.get('/user/12345', {
1465-
headers: { Authorization: 'Bearer token' },
1466-
redact: ['authorization']
1467-
}).catch(function (error) {
1468-
console.log(error.toJSON().config.headers.Authorization); // [REDACTED ****]
1469-
});
1469+
axios
1470+
.get('/user/12345', {
1471+
headers: { Authorization: 'Bearer token' },
1472+
redact: ['authorization'],
1473+
})
1474+
.catch(function (error) {
1475+
console.log(error.toJSON().config.headers.Authorization); // [REDACTED ****]
1476+
});
14701477
```
14711478
14721479
## Handling timeouts
@@ -1576,11 +1583,44 @@ axios.get('/user/12345', {
15761583
cancel();
15771584
```
15781585
1586+
`CancelToken` also exposes low-level helpers for legacy integrations:
1587+
1588+
```js
1589+
const source = axios.CancelToken.source();
1590+
1591+
const listener = (cancel) => {
1592+
console.log(cancel.message);
1593+
};
1594+
1595+
source.token.subscribe(listener);
1596+
1597+
const signal = source.token.toAbortSignal();
1598+
// Pass `signal` to APIs that accept AbortSignal.
1599+
1600+
source.cancel('Operation canceled by the user.');
1601+
source.token.unsubscribe(listener);
1602+
```
1603+
1604+
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.
1605+
15791606
> Note: You can cancel several requests with the same cancel token or abort controller.
15801607
> If a cancellation token is already cancelled when an Axios request starts, Axios cancels the request immediately without making a real request.
15811608
15821609
> During the transition period, you can use both cancellation APIs, even for the same request:
15831610
1611+
```js
1612+
const controller = new AbortController();
1613+
const source = axios.CancelToken.source();
1614+
1615+
axios.get('/user/12345', {
1616+
cancelToken: source.token,
1617+
signal: controller.signal,
1618+
});
1619+
1620+
controller.abort();
1621+
source.cancel('Operation canceled by the user.');
1622+
```
1623+
15841624
## Using `application/x-www-form-urlencoded` format
15851625
15861626
### URLSearchParams
@@ -1782,6 +1822,9 @@ FormData serializer supports additional options via `config.formSerializer: obje
17821822
input object exceeds this depth, an `AxiosError` with `code: 'ERR_FORM_DATA_DEPTH_EXCEEDED'` is
17831823
thrown instead of overflowing the call stack. This protects server applications from DoS
17841824
attacks via deeply nested payloads. Set to `Infinity` to disable the limit and restore pre-fix behaviour.
1825+
- `Blob: typeof Blob` - Blob constructor used when converting ArrayBuffer-like values for spec-compliant
1826+
`FormData`. Override it only for runtimes that provide a compatible `Blob` constructor under a
1827+
different binding.
17851828
17861829
```js
17871830
// Raise the limit for a schema that genuinely nests deeper than 100 levels:
@@ -2108,6 +2151,7 @@ console.log(headers);
21082151
set(headerName, value: Axios, rewrite?: boolean);
21092152
set(headerName, value, rewrite?: (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean);
21102153
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean);
2154+
set(headers?: Iterable<[string, AxiosHeaderValue]>, rewrite?: boolean);
21112155
```
21122156
21132157
The `rewrite` argument controls the overwriting behavior:
@@ -2120,6 +2164,19 @@ The option can also accept a user-defined function that determines whether to ov
21202164
21212165
Empty or whitespace-only header names are ignored.
21222166
2167+
Iterable key/value pairs, such as a `Map`, are accepted:
2168+
2169+
```js
2170+
const headers = new AxiosHeaders();
2171+
2172+
headers.set(
2173+
new Map([
2174+
['X-Trace-Id', 'abc123'],
2175+
['Accept', 'application/json'],
2176+
])
2177+
);
2178+
```
2179+
21232180
Returns `this`.
21242181
21252182
### AxiosHeaders#get(header)
@@ -2240,6 +2297,14 @@ toJSON(asStrings?: false): Record<string, string | string[]>;
22402297
Resolves all internal header values into a new null prototype object.
22412298
Set `asStrings` to true to resolve arrays as a string containing all elements, separated by commas.
22422299
2300+
### AxiosHeaders#toString()
2301+
2302+
```
2303+
toString(): string;
2304+
```
2305+
2306+
Returns the headers as a CRLF-free HTTP header block, one `name: value` pair per line.
2307+
22432308
### AxiosHeaders.from(thing?)
22442309
22452310
```

0 commit comments

Comments
 (0)