axios 1.16.0 → 1.17.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/README.md CHANGED
@@ -29,27 +29,10 @@
29
29
  </td>
30
30
  <td align="center" width="50%">
31
31
  <a
32
- href="https://hopper.security/?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship"
33
- style="padding: 10px; display: inline-block"
32
+ href="https://opencollective.com/axios/contribute"
34
33
  target="_blank"
34
+ >💜 Become a sponsor</a
35
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&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship"
49
- target="_blank"
50
- ><b>hopper.security</b></a
51
- >
52
- </p>
53
36
  </td>
54
37
  </tr>
55
38
  </table>
@@ -142,7 +125,7 @@
142
125
  </a>
143
126
  <p
144
127
  align="center"
145
- title="Hi, we&#x27;re Descope! We are building something in the authentication space for app developers and cant wait to place it in your hands."
128
+ title="Hi, we&#x27;re Descope! We are building something in the authentication space for app developers and can't wait to place it in your hands."
146
129
  >
147
130
  Reduce user friction, prevent account takeover, and get a 360° view of your customer and agentic identities with the Descope External IAM platform.
148
131
  </p>
@@ -244,14 +227,13 @@
244
227
  width="71px"
245
228
  height="70px"
246
229
  src="https://images.opencollective.com/buzzoid-buy-instagram-followers/56a09fe/logo.png"
247
- alt="Buzzoid"
230
+ alt="Buzzoid - Buy Instagram Followers"
248
231
  />
249
232
  </a>
250
233
  <p
251
234
  align="center"
252
235
  >
253
- A lightweight open-source API Development, Testing &amp; Mocking
254
- platform
236
+ At Buzzoid, you can buy Instagram followers through a short checkout flow with safety controls. Rated world&#39;s #1 IG service since 2012.
255
237
  </p>
256
238
  <p align="center">
257
239
  <a
@@ -263,17 +245,55 @@
263
245
  </td>
264
246
  <td align="center" width="33.333333333333336%">
265
247
  <a
266
- href="https://opencollective.com/axios/contribute"
248
+ href="https://twicsy.com/buy-instagram-followers/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
249
+ style="padding: 10px; display: inline-block"
267
250
  target="_blank"
268
- >💜 Become a sponsor</a
269
251
  >
252
+ <img
253
+ width="71px"
254
+ height="70px"
255
+ src="https://images.opencollective.com/buy-instagram-followers-twicsy/b4c5d7f/logo/256.png?height=256"
256
+ alt="Buy Instagram Followers Twicsy"
257
+ />
258
+ </a>
259
+ <p
260
+ align="center"
261
+ >
262
+ Buy real Instagram followers from Twicsy. Twicsy has been voted the best site to buy followers from the likes of US Magazine.
263
+ </p>
264
+ <p align="center">
265
+ <a
266
+ href="https://twicsy.com/buy-instagram-followers/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
267
+ target="_blank"
268
+ ><b>twicsy.com</b></a
269
+ >
270
+ </p>
270
271
  </td>
271
272
  <td align="center" width="33.333333333333336%">
272
273
  <a
273
- href="https://opencollective.com/axios/contribute"
274
+ href="https://global.fun88.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
275
+ style="padding: 10px; display: inline-block"
274
276
  target="_blank"
275
- >💜 Become a sponsor</a
276
277
  >
278
+ <img
279
+ width="71px"
280
+ height="70px"
281
+ src="https://images.opencollective.com/fun88-official/bf2843c/logo.png"
282
+ alt="Fun 88"
283
+ />
284
+ </a>
285
+ <p
286
+ align="center"
287
+ >
288
+ Fun88 is a global online gambling and betting brand founded in 2009, offering a wide range of services including sports betting, live casino games, slots, and virtual gaming.
289
+ </p>
290
+ <p align="center">
291
+ <a
292
+ href="https://global.fun88.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
293
+ target="_blank"
294
+ ><b>global.fun88.com</b></a
295
+ >
296
+ </p>
277
297
  </td>
278
298
  </tr>
279
299
  </table>
@@ -297,62 +317,61 @@
297
317
  <div align="center">
298
318
 
299
319
  [![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
300
- [![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios)
301
320
  [![Build status](https://img.shields.io/github/actions/workflow/status/axios/axios/ci.yml?branch=v1.x&label=CI&logo=github&style=flat-square)](https://github.com/axios/axios/actions/workflows/ci.yml)
302
321
  [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod&style=flat-square)](https://gitpod.io/#https://github.com/axios/axios)
303
- [![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios)
304
322
  [![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=axios&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=axios)
305
323
  [![npm bundle size](https://img.shields.io/bundlephobia/minzip/axios?style=flat-square)](https://bundlephobia.com/package/axios@latest)
306
324
  [![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](https://npm-stat.com/charts.html?package=axios)
307
325
  [![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios)
308
326
  [![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios)
309
327
  [![Contributors](https://img.shields.io/github/contributors/axios/axios.svg?style=flat-square)](CONTRIBUTORS.md)
328
+ [![Agent Friendly](https://agentfriendlycode.com/api/badge/github/axios/axios.svg)](https://agentfriendlycode.com/repo/32)
310
329
 
311
330
  </div>
312
331
 
313
- ## Table of Contents
332
+ ## Table of contents
314
333
 
315
334
  - [Features](#features)
316
- - [Browser Support](#browser-support)
335
+ - [Browser support](#browser-support)
317
336
  - [Installing](#installing)
318
337
  - [Package manager](#package-manager)
319
338
  - [CDN](#cdn)
320
339
  - [Example](#example)
321
340
  - [Axios API](#axios-api)
322
341
  - [Request method aliases](#request-method-aliases)
323
- - [Concurrency 👎](#concurrency-deprecated)
342
+ - [Concurrency](#concurrency-deprecated)
324
343
  - [Creating an instance](#creating-an-instance)
325
344
  - [Instance methods](#instance-methods)
326
- - [Request Config](#request-config)
327
- - [Response Schema](#response-schema)
328
- - [Config Defaults](#config-defaults)
345
+ - [Request config](#request-config)
346
+ - [Response schema](#response-schema)
347
+ - [Config defaults](#config-defaults)
329
348
  - [Global axios defaults](#global-axios-defaults)
330
349
  - [Custom instance defaults](#custom-instance-defaults)
331
350
  - [Config order of precedence](#config-order-of-precedence)
332
351
  - [Interceptors](#interceptors)
333
- - [Multiple Interceptors](#multiple-interceptors)
334
- - [Handling Errors](#handling-errors)
335
- - [Handling Timeouts](#handling-timeouts)
352
+ - [Multiple interceptors](#multiple-interceptors)
353
+ - [Handling errors](#handling-errors)
354
+ - [Handling timeouts](#handling-timeouts)
336
355
  - [Cancellation](#cancellation)
337
356
  - [AbortController](#abortcontroller)
338
- - [CancelToken 👎](#canceltoken-deprecated)
357
+ - [CancelToken](#canceltoken-deprecated)
339
358
  - [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format)
340
359
  - [URLSearchParams](#urlsearchparams)
341
360
  - [Query string](#query-string-older-browsers)
342
- - [🆕 Automatic serialization](#-automatic-serialization-to-urlsearchparams)
361
+ - [Automatic serialization](#automatic-serialization-to-urlsearchparams)
343
362
  - [Using multipart/form-data format](#using-multipartform-data-format)
344
363
  - [FormData](#formdata)
345
- - [🆕 Automatic serialization](#-automatic-serialization-to-formdata)
346
- - [Files Posting](#files-posting)
347
- - [HTML Form Posting](#-html-form-posting-browser)
348
- - [🆕 Progress capturing](#-progress-capturing)
349
- - [🆕 Rate limiting](#-rate-limiting)
350
- - [🆕 AxiosHeaders](#-axiosheaders)
351
- - [🔥 Fetch adapter](#-fetch-adapter)
352
- - [🔥 Custom fetch](#-custom-fetch)
353
- - [🔥 Using with Tauri](#-using-with-tauri)
354
- - [🔥 Using with SvelteKit](#-using-with-sveltekit)
355
- - [🔥 HTTP2](#-http2)
364
+ - [Automatic serialization](#automatic-serialization-to-formdata)
365
+ - [Posting files](#posting-files)
366
+ - [HTML form posting](#html-form-posting-browser)
367
+ - [Progress capturing](#progress-capturing)
368
+ - [Rate limiting](#rate-limiting)
369
+ - [AxiosHeaders](#axiosheaders)
370
+ - [Fetch adapter](#fetch-adapter)
371
+ - [Custom fetch](#custom-fetch)
372
+ - [Using with Tauri](#using-with-tauri)
373
+ - [Using with SvelteKit](#using-with-sveltekit)
374
+ - [HTTP/2 support](#http2-support)
356
375
  - [Semver](#semver)
357
376
  - [Promises](#promises)
358
377
  - [TypeScript](#typescript)
@@ -364,17 +383,17 @@
364
383
 
365
384
  ## Features
366
385
 
367
- - **Browser Requests:** Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) directly from the browser.
368
- - **Node.js Requests:** Make [http](https://nodejs.org/api/http.html) requests from Node.js environments.
369
- - **Promise-based:** Fully supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API for easier asynchronous code.
370
- - **Interceptors:** Intercept requests and responses to add custom logic or transform data.
371
- - **Data Transformation:** Transform request and response data automatically.
372
- - **Request Cancellation:** Cancel requests using built-in mechanisms.
373
- - **Automatic JSON Handling:** Automatically serializes and parses [JSON](https://www.json.org/json-en.html) data.
374
- - **Form Serialization:** 🆕 Automatically serializes data objects to `multipart/form-data` or `x-www-form-urlencoded` formats.
375
- - **XSRF Protection:** Client-side support to protect against [Cross-Site Request Forgery](https://en.wikipedia.org/wiki/Cross-site_request_forgery).
386
+ - Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser.
387
+ - Make [http](https://nodejs.org/api/http.html) requests from Node.js.
388
+ - Use the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API for asynchronous request handling.
389
+ - Intercept requests and responses to add custom logic or transform data.
390
+ - Transform request and response data.
391
+ - Cancel requests with built-in cancellation APIs.
392
+ - Serialize and parse [JSON](https://www.json.org/json-en.html) data.
393
+ - Serialize data objects to `multipart/form-data` or `application/x-www-form-urlencoded`.
394
+ - Add client-side protection against [Cross-Site Request Forgery](https://en.wikipedia.org/wiki/Cross-site_request_forgery).
376
395
 
377
- ## Browser Support
396
+ ## Browser support
378
397
 
379
398
  | Chrome | Firefox | Safari | Opera | Edge |
380
399
  | :------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------: |
@@ -411,7 +430,7 @@ Using bun:
411
430
  $ bun add axios
412
431
  ```
413
432
 
414
- Once the package is installed, you can import the library using `import` or `require` approach:
433
+ Once the package is installed, import it with `import` or `require`:
415
434
 
416
435
  ```js
417
436
  import axios, { isCancel, AxiosError } from 'axios';
@@ -433,14 +452,13 @@ const axios = require('axios');
433
452
  console.log(axios.isCancel('something'));
434
453
  ```
435
454
 
436
- For some bundlers and some ES6 linters you may need to do the following:
455
+ Some bundlers and ES6 linters need this form:
437
456
 
438
457
  ```js
439
458
  import { default as axios } from 'axios';
440
459
  ```
441
460
 
442
- For cases where something went wrong when trying to import a module into a custom or legacy environment,
443
- you can try importing the module package directly:
461
+ In custom or legacy environments, you can import the bundle directly:
444
462
 
445
463
  ```js
446
464
  const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundle (ES2017)
@@ -480,7 +498,7 @@ axios
480
498
  params: {
481
499
  ID: 12345,
482
500
  },
483
- timeout: 5000, // 5 seconds see "Handling Timeouts" below for matching error handling
501
+ timeout: 5000, // 5 seconds. See "Handling Timeouts" below for matching error handling
484
502
  })
485
503
  .then(function (response) {
486
504
  console.log(response);
@@ -495,18 +513,26 @@ axios
495
513
  // Want to use async/await? Add the `async` keyword to your outer function/method.
496
514
  async function getUser() {
497
515
  try {
498
- const response = await axios.get('/user?ID=12345');
499
- console.log(response);
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);
500
526
  } catch (error) {
501
527
  console.error(error);
502
528
  }
503
529
  }
504
530
  ```
505
531
 
506
- > **Note**: Set a `timeout` in production without one, a stalled request can hang
532
+ > Note: Set a `timeout` in production. Without one, a stalled request can hang
507
533
  > indefinitely. See [Handling Timeouts](#handling-timeouts) for the matching error handling.
508
534
 
509
- > **Note**: `async/await` is part of ECMAScript 2017 and is not supported in Internet
535
+ > Note: `async/await` is part of ECMAScript 2017 and is not supported in Internet
510
536
  > Explorer and older browsers, so use with caution.
511
537
 
512
538
  Performing a `POST` request
@@ -591,13 +617,13 @@ For convenience, aliases have been provided for all common request methods.
591
617
 
592
618
  ##### axios.patch(url[, data[, config]])
593
619
 
594
- ###### NOTE
620
+ ###### Note
595
621
 
596
622
  When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config.
597
623
 
598
- ### Concurrency (Deprecated)
624
+ ### Concurrency (deprecated)
599
625
 
600
- Please use `Promise.all` to replace the below functions.
626
+ Use `Promise.all` instead of these helpers.
601
627
 
602
628
  Helper functions for dealing with concurrent requests.
603
629
 
@@ -620,7 +646,7 @@ const instance = axios.create({
620
646
 
621
647
  ### Instance methods
622
648
 
623
- The available instance methods are listed below. The specified config will be merged with the instance config.
649
+ The following instance methods are available. Axios merges the specified config with the instance config.
624
650
 
625
651
  ##### axios#request(config)
626
652
 
@@ -640,11 +666,11 @@ The available instance methods are listed below. The specified config will be me
640
666
 
641
667
  ##### axios#getUri([config])
642
668
 
643
- ## Request Config
669
+ ## Request config
644
670
 
645
- ### ⚠️ Security notice: decompression-bomb protection is opt-in
671
+ ### Security notice: decompression-bomb protection is opt-in
646
672
 
647
- By default `maxContentLength` and `maxBodyLength` are `-1` (unlimited). A malicious or compromised server can return a tiny gzip/deflate/brotli body that expands to gigabytes and exhaust the Node.js process.
673
+ By default `maxContentLength` and `maxBodyLength` are `-1` (unlimited). A malicious or compromised server can return a tiny gzip/deflate/brotli/zstd body that expands to gigabytes and exhaust the Node.js process.
648
674
 
649
675
  If you call servers you do not fully trust, **set a cap**:
650
676
 
@@ -655,17 +681,17 @@ axios.defaults.maxBodyLength = 10 * 1024 * 1024;
655
681
 
656
682
  See the [security guide](https://axios.rest/pages/misc/security.html) for details.
657
683
 
658
- These are the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified.
684
+ These config options are available for requests. Only `url` is required. Requests default to `GET` when `method` is not set.
659
685
 
660
686
  ```js
661
687
  {
662
- // `url` is the server URL that will be used for the request
688
+ // `url` is the server URL for the request
663
689
  url: '/user',
664
690
 
665
691
  // `method` is the request method to be used when making the request
666
692
  method: 'get', // default
667
693
 
668
- // `baseURL` will be prepended to `url` unless `url` is absolute and the option `allowAbsoluteUrls` is set to true.
694
+ // Axios prepends `baseURL` to `url` unless `url` is absolute and `allowAbsoluteUrls` is set to true.
669
695
  // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
670
696
  // to the methods of that instance.
671
697
  baseURL: 'https://some-domain.com/api/',
@@ -694,7 +720,7 @@ These are the available config options for making requests. Only the `url` is re
694
720
  return data;
695
721
  }],
696
722
 
697
- // `parseReviver` is an optional function that will be passed as the
723
+ // `parseReviver` is an optional function passed as the
698
724
  // second argument (reviver) to JSON.parse()
699
725
  parseReviver: function (key, value, context) {
700
726
  // In modern environments, context.source provides the raw JSON string
@@ -763,7 +789,7 @@ These are the available config options for making requests. Only the `url` is re
763
789
  data: 'Country=Brasil&City=Belo Horizonte',
764
790
 
765
791
  // `timeout` specifies the number of milliseconds before the request times out.
766
- // If the request takes longer than `timeout`, the request will be aborted.
792
+ // If the request takes longer than `timeout`, Axios aborts it.
767
793
  timeout: 1000, // default is `0` (no timeout)
768
794
 
769
795
  // `withCredentials` indicates whether or not cross-site Access-Control requests
@@ -784,6 +810,12 @@ These are the available config options for making requests. Only the `url` is re
784
810
  // `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
785
811
  // This will set an `Authorization` header, overwriting any existing
786
812
  // `Authorization` custom headers you have set using `headers`.
813
+ // If `auth` is omitted, the Node.js HTTP and fetch adapters can read
814
+ // HTTP Basic auth credentials from the request URL, for example
815
+ // `https://user:pass@example.com`. Axios decodes percent-encoded URL
816
+ // credentials, and `auth` takes precedence over URL-embedded credentials.
817
+ // The Node.js HTTP adapter preserves Basic auth on same-origin redirects
818
+ // and strips it on cross-origin redirects.
787
819
  // Please note that only HTTP Basic auth is configurable through this parameter.
788
820
  // For Bearer tokens and such, use `Authorization` custom headers instead.
789
821
  auth: {
@@ -857,17 +889,16 @@ These are the available config options for making requests. Only the `url` is re
857
889
 
858
890
  // `validateStatus` defines whether to resolve or reject the promise for a given
859
891
  // HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
860
- // or `undefined`), the promise will be resolved; otherwise, the promise will be
861
- // rejected.
892
+ // or `undefined`), Axios resolves the promise; otherwise, Axios rejects it.
862
893
  validateStatus: function (status) {
863
894
  return status >= 200 && status < 300; // default
864
895
  },
865
896
 
866
897
  // `maxRedirects` defines the maximum number of redirects to follow in node.js.
867
- // If set to 0, no redirects will be followed.
898
+ // If set to 0, Axios follows no redirects.
868
899
  maxRedirects: 21, // default
869
900
 
870
- // `beforeRedirect` defines a function that will be called before redirect.
901
+ // `beforeRedirect` defines a function that Axios calls before redirect.
871
902
  // Use this to adjust the request options upon redirecting,
872
903
  // to inspect the latest response headers,
873
904
  // or to cancel the request by throwing an error
@@ -883,16 +914,10 @@ These are the available config options for making requests. Only the `url` is re
883
914
  },
884
915
  // Security note:
885
916
  // The `beforeRedirect` hook runs after sensitive headers are stripped during redirects.
886
- //The `follow-redirects` library removes credentials on protocol downgrade (HTTPS → HTTP) for security.
887
- //Since `beforeRedirect` runs after this, re-injecting credentials without checking the protocol can expose sensitive data.
888
- //Always ensure credentials are only added for trusted HTTPS destinations.
889
-
890
- // Security note:
891
- // The beforeRedirect hook runs after sensitive headers are stripped during redirects.
892
- // Re-injecting credentials without checking the destination can expose sensitive data.
893
- // Only add credentials for trusted HTTPS destinations.
894
- // Avoid re-adding credentials on downgraded redirects.
895
-
917
+ // `follow-redirects` removes credentials on protocol downgrades
918
+ // (HTTPS to HTTP). Because `beforeRedirect` runs after that step,
919
+ // re-injecting credentials without checking the destination can expose
920
+ // sensitive data. Only add credentials for trusted HTTPS destinations.
896
921
 
897
922
  // `socketPath` defines a UNIX Socket to be used in node.js.
898
923
  // e.g. '/var/run/docker.sock' to send requests to the docker daemon.
@@ -911,10 +936,10 @@ These are the available config options for making requests. Only the `url` is re
911
936
  // `ERR_BAD_OPTION_VALUE`. When null/undefined, no restriction is applied.
912
937
  allowedSocketPaths: null, // default
913
938
 
914
- // `transport` determines the transport method that will be used to make the request.
915
- // If defined, it will be used. Otherwise, if `maxRedirects` is 0,
916
- // the default `http` or `https` library will be used, depending on the protocol specified in `protocol`.
917
- // Otherwise, the `httpFollow` or `httpsFollow` library will be used, again depending on the protocol,
939
+ // `transport` determines the transport method for the request.
940
+ // If defined, Axios uses it. Otherwise, if `maxRedirects` is 0,
941
+ // Axios uses the default `http` or `https` library, depending on the protocol specified in `protocol`.
942
+ // Otherwise, Axios uses the `httpFollow` or `httpsFollow` library, again depending on the protocol,
918
943
  // which can handle redirects.
919
944
  transport: undefined, // default
920
945
 
@@ -934,15 +959,27 @@ These are the available config options for making requests. Only the `url` is re
934
959
  // Use `false` to disable proxies, ignoring environment variables.
935
960
  // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
936
961
  // supplies credentials.
937
- // This will set a `Proxy-Authorization` header, overwriting any existing
938
- // `Proxy-Authorization` custom headers you have set using `headers`.
962
+ // For `http://` targets, axios sends the request to the proxy in
963
+ // forward-proxy mode and stamps `Proxy-Authorization` onto the request
964
+ // headers (overwriting any user-supplied `Proxy-Authorization` header).
965
+ // For `https://` targets, axios establishes a CONNECT tunnel through the
966
+ // proxy and performs TLS end-to-end with the origin; `Proxy-Authorization`
967
+ // is sent on the CONNECT request only, never on the wrapped TLS request,
968
+ // so the proxy never sees the URL, headers, or body. Axios forwards
969
+ // `httpsAgent` TLS options such as `ca`, `cert`, `key`, and
970
+ // `rejectUnauthorized` to the generated tunneling agent, so they still apply
971
+ // to the origin TLS connection.
972
+ // If you supply an `HttpsProxyAgent`, axios leaves tunneling to that agent.
939
973
  // If the proxy server uses HTTPS, then you must set the protocol to `https`.
940
974
  // A user-supplied `Host` header in `headers` is preserved when forwarding
941
975
  // through a proxy (case-insensitive match on `host`/`Host`/`HOST`); this
942
- // lets you target a virtual host that differs from the request URL for
976
+ // lets you target a virtual host that differs from the request URL, for
943
977
  // example, hitting `127.0.0.1:4000` while having the proxy treat the
944
978
  // request as `example.com`. If no `Host` header is supplied, axios
945
- // defaults it to the request URL's `hostname:port` as before.
979
+ // defaults it to the request URL's `hostname:port` as before. The Host
980
+ // header is only set in forward-proxy mode (HTTP targets); for HTTPS
981
+ // tunneling the Host header is sent inside the TLS connection, not seen
982
+ // by the proxy.
946
983
  proxy: {
947
984
  protocol: 'https',
948
985
  host: '127.0.0.1',
@@ -965,6 +1002,8 @@ These are the available config options for making requests. Only the `url` is re
965
1002
  // `decompress` indicates whether or not the response body should be decompressed
966
1003
  // automatically. If set to `true` will also remove the 'content-encoding' header
967
1004
  // from the responses objects of all decompressed responses
1005
+ // Axios supports gzip, deflate, brotli, and zstd when the current Node.js
1006
+ // runtime provides the corresponding zlib decompressor.
968
1007
  // - Node only (XHR cannot turn off decompression)
969
1008
  decompress: true, // default
970
1009
 
@@ -994,6 +1033,11 @@ These are the available config options for making requests. Only the `url` is re
994
1033
  // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
995
1034
  clarifyTimeoutError: false,
996
1035
 
1036
+ // advertise `zstd` in the default Accept-Encoding header when the current
1037
+ // Node.js runtime supports zstd decompression. Axios still decompresses
1038
+ // zstd responses when support exists and `decompress` is true.
1039
+ advertiseZstdAcceptEncoding: false,
1040
+
997
1041
  // use the legacy interceptor request/response ordering
998
1042
  legacyInterceptorReqResOrdering: true, // default
999
1043
  },
@@ -1038,17 +1082,17 @@ const client = axios.create({
1038
1082
  });
1039
1083
  ```
1040
1084
 
1041
- ## 🔥 HTTP/2 Support
1085
+ ## HTTP/2 support
1042
1086
 
1043
- Axios has experimental HTTP/2 support available via the Node.js HTTP adapter.
1087
+ Axios has experimental HTTP/2 support in the Node.js HTTP adapter.
1044
1088
 
1045
- Support depends on the runtime environment and Node.js version. Features like redirects and some behaviors may not be fully supported with HTTP/2.
1089
+ Support depends on the runtime environment and Node.js version. Redirects and some adapter behavior may differ from HTTP/1.1.
1046
1090
 
1047
- Options like `httpVersion` and `http2Options` are adapter-specific and may not work consistently across all environments.
1091
+ Options like `httpVersion` and `http2Options` are adapter-specific and may not work the same way in every environment.
1048
1092
 
1049
- If HTTP/2 functionality is required, ensure your runtime environment supports it or consider using alternative libraries or custom adapters.
1093
+ If you need HTTP/2, check runtime support or use a custom adapter.
1050
1094
 
1051
- ## Response Schema
1095
+ ## Response schema
1052
1096
 
1053
1097
  The response to a request contains the following information.
1054
1098
 
@@ -1078,7 +1122,7 @@ The response to a request contains the following information.
1078
1122
  }
1079
1123
  ```
1080
1124
 
1081
- When using `then`, you will receive the response as follows:
1125
+ When using `then`, you receive the response like this:
1082
1126
 
1083
1127
  ```js
1084
1128
  const response = await axios.get('/user/12345');
@@ -1089,18 +1133,18 @@ console.log(response.headers);
1089
1133
  console.log(response.config);
1090
1134
  ```
1091
1135
 
1092
- When using `catch`, or passing a [rejection callback](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) as second parameter of `then`, the response will be available through the `error` object as explained in the [Handling Errors](#handling-errors) section.
1136
+ When using `catch`, or passing a [rejection callback](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) as the second parameter of `then`, read the response from the `error` object. See [Handling errors](#handling-errors).
1093
1137
 
1094
- ## Config Defaults
1138
+ ## Config defaults
1095
1139
 
1096
- You can specify config defaults that will be applied to every request.
1140
+ Config defaults apply to every request.
1097
1141
 
1098
1142
  ### Global axios defaults
1099
1143
 
1100
1144
  ```js
1101
1145
  axios.defaults.baseURL = 'https://api.example.com';
1102
1146
 
1103
- // Important: If axios is used with multiple domains, the AUTH_TOKEN will be sent to all of them.
1147
+ // Important: If you use axios with multiple domains, Axios sends AUTH_TOKEN to all of them.
1104
1148
  // See below for an example using Custom instance defaults instead.
1105
1149
  axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
1106
1150
 
@@ -1121,7 +1165,7 @@ instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
1121
1165
 
1122
1166
  ### Config order of precedence
1123
1167
 
1124
- Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults/index.js](https://github.com/axios/axios/blob/main/lib/defaults/index.js#L49), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example.
1168
+ 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.
1125
1169
 
1126
1170
  ```js
1127
1171
  // Create an instance using the config defaults provided by the library
@@ -1180,7 +1224,7 @@ const instance = axios.create();
1180
1224
  const myInterceptor = instance.interceptors.request.use(function () {
1181
1225
  /*...*/
1182
1226
  });
1183
- axios.interceptors.request.eject(myInterceptor);
1227
+ instance.interceptors.request.eject(myInterceptor);
1184
1228
  ```
1185
1229
 
1186
1230
  You can also clear all interceptors for requests or responses.
@@ -1223,8 +1267,8 @@ axios.interceptors.request.use(
1223
1267
  ```
1224
1268
 
1225
1269
  If you want to execute a particular interceptor based on a runtime check,
1226
- you can add a `runWhen` function to the options object. The request interceptor will not be executed **if and only if** the return
1227
- of `runWhen` is `false`. The function will be called with the config
1270
+ you can add a `runWhen` function to the options object. The request interceptor will not run **if and only if** the return
1271
+ of `runWhen` is `false`. Axios calls the function with the config
1228
1272
  object (don't forget that you can bind your own arguments to it as well.) This can be handy when you have an
1229
1273
  asynchronous request interceptor that only needs to run at certain times.
1230
1274
 
@@ -1242,15 +1286,15 @@ axios.interceptors.request.use(
1242
1286
  );
1243
1287
  ```
1244
1288
 
1245
- > **Note:** The options parameter(having `synchronous` and `runWhen` properties) is only supported for request interceptors at the moment.
1289
+ > Note: The options parameter (with `synchronous` and `runWhen` properties) is only supported for request interceptors at the moment.
1246
1290
 
1247
- ### Interceptor Execution Order
1291
+ ### Interceptor execution order
1248
1292
 
1249
- **Important:** Interceptors have different execution orders depending on their type!
1293
+ Request and response interceptors use different execution orders.
1250
1294
 
1251
- Request interceptors are executed in **reverse order** (LIFO - Last In, First Out). This means the _last_ interceptor added is executed **first**.
1295
+ Request interceptors run in reverse order (LIFO: last in, first out). The last interceptor added runs first.
1252
1296
 
1253
- Response interceptors are executed in the **order they were added** (FIFO - First In, First Out). This means the _first_ interceptor added is executed **first**.
1297
+ Response interceptors run in the order they were added (FIFO: first in, first out). The first interceptor added runs first.
1254
1298
 
1255
1299
  Example:
1256
1300
 
@@ -1279,37 +1323,33 @@ instance.interceptors.response.use(interceptor('Response Interceptor 3'));
1279
1323
  // Response Interceptor 3
1280
1324
  ```
1281
1325
 
1282
- ### Multiple Interceptors
1326
+ ### Multiple interceptors
1283
1327
 
1284
- Given that you add multiple response interceptors
1285
- and when the response was fulfilled
1328
+ When a response is fulfilled and multiple response interceptors are registered:
1286
1329
 
1287
- - then each interceptor is executed
1288
- - then they are executed in the order they were added
1289
- - then only the last interceptor's result is returned
1290
- - then every interceptor receives the result of its predecessor
1291
- - and when the fulfillment-interceptor throws
1292
- - then the following fulfillment-interceptor is not called
1293
- - then the following rejection-interceptor is called
1294
- - once caught, another following fulfill-interceptor is called again (just like in a promise chain).
1330
+ - Each interceptor runs in registration order.
1331
+ - Each interceptor receives the result from the previous interceptor.
1332
+ - The chain returns the result from the last interceptor.
1333
+ - If a fulfillment interceptor throws, Axios skips the next fulfillment interceptor and calls the next rejection interceptor.
1334
+ - After the error is caught, later fulfillment interceptors run again, just like in a promise chain.
1295
1335
 
1296
1336
  Read [the interceptor tests](./test/specs/interceptors.spec.js) to see all this in code.
1297
1337
 
1298
- ## Error Types
1338
+ ## Error types
1299
1339
 
1300
- There are many different axios error messages that can appear which can provide basic information about the specifics of the error and where opportunities may lie in debugging.
1340
+ Axios error messages include details that can help you debug the request.
1301
1341
 
1302
- The general structure of axios errors is as follows:
1342
+ Axios errors use this structure:
1303
1343
  | Property | Definition |
1304
1344
  | -------- | ---------- |
1305
1345
  | message | A quick summary of the error message and the status it failed with. |
1306
1346
  | name | This defines where the error originated from. For axios, it will always be an 'AxiosError'. |
1307
- | stack | Provides the stack trace of the error. |
1347
+ | stack | Stack trace for the error. |
1308
1348
  | config | An axios config object with specific instance configurations defined by the user from when the request was made |
1309
- | code | Represents an axios identified error. The table below lists specific definitions for internal axios error. |
1349
+ | code | Axios error code. The table below lists internal Axios error codes. |
1310
1350
  | status | HTTP response status code. See [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for common HTTP response status code meanings.
1311
1351
 
1312
- Below is a list of potential axios identified error:
1352
+ These are the internal Axios error codes:
1313
1353
 
1314
1354
  | Code | Definition |
1315
1355
  | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -1319,16 +1359,16 @@ Below is a list of potential axios identified error:
1319
1359
  | ERR_DEPRECATED | Deprecated feature or method used in axios. |
1320
1360
  | ERR_INVALID_URL | Invalid URL provided for axios request. |
1321
1361
  | ECONNABORTED | Typically indicates that the request has been timed out (unless `transitional.clarifyTimeoutError` is set) or aborted by the browser or its plugin. |
1322
- | ERR_CANCELED | Feature or method is canceled explicitly by the user using an AbortSignal (or a CancelToken). |
1323
- | ETIMEDOUT | Request timed out due to exceeding the default axios timelimit. `transitional.clarifyTimeoutError` must be set to `true`, otherwise a generic `ECONNABORTED` error will be thrown instead. |
1362
+ | ERR_CANCELED | The user explicitly canceled the request with an AbortSignal or CancelToken. |
1363
+ | ETIMEDOUT | Request timed out after exceeding the configured Axios timeout. Set `transitional.clarifyTimeoutError` to `true`; otherwise Axios throws a generic `ECONNABORTED` error. |
1324
1364
  | 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. |
1325
- | ERR_FR_TOO_MANY_REDIRECTS | Request is redirected too many times; exceeds max redirects specified in axios configuration. |
1365
+ | ERR_FR_TOO_MANY_REDIRECTS | Request exceeded the configured maximum number of redirects. |
1326
1366
  | ERR_BAD_RESPONSE | Response cannot be parsed properly or is in an unexpected format. Usually related to a response with `5xx` status code. |
1327
1367
  | ERR_BAD_REQUEST | The request has an unexpected format or is missing required parameters. Usually related to a response with `4xx` status code. |
1328
1368
 
1329
- ## Handling Errors
1369
+ ## Handling errors
1330
1370
 
1331
- 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.
1371
+ By default, Axios rejects responses with status codes outside the 2xx range.
1332
1372
 
1333
1373
  ```js
1334
1374
  axios.get('/user/12345').catch(function (error) {
@@ -1351,7 +1391,7 @@ axios.get('/user/12345').catch(function (error) {
1351
1391
  });
1352
1392
  ```
1353
1393
 
1354
- Using the `validateStatus` config option, you can override the default condition (status >= 200 && status < 300) and define HTTP code(s) that should throw an error.
1394
+ Use `validateStatus` to override the default condition (`status >= 200 && status < 300`) and choose which HTTP status codes should reject.
1355
1395
 
1356
1396
  ```js
1357
1397
  axios.get('/user/12345', {
@@ -1361,7 +1401,7 @@ axios.get('/user/12345', {
1361
1401
  });
1362
1402
  ```
1363
1403
 
1364
- Using `toJSON` you get an object with more information about the HTTP error.
1404
+ Use `toJSON` to get more information about the HTTP error.
1365
1405
 
1366
1406
  ```js
1367
1407
  axios.get('/user/12345').catch(function (error) {
@@ -1380,7 +1420,7 @@ axios.get('/user/12345', {
1380
1420
  });
1381
1421
  ```
1382
1422
 
1383
- ## Handling Timeouts
1423
+ ## Handling timeouts
1384
1424
 
1385
1425
  ```js
1386
1426
  async function fetchWithTimeout() {
@@ -1414,7 +1454,7 @@ async function fetchWithTimeout() {
1414
1454
 
1415
1455
  ### AbortController
1416
1456
 
1417
- Starting from `v0.22.0` Axios supports AbortController to cancel requests in a fetch API way:
1457
+ Since `v0.22.0`, Axios supports AbortController:
1418
1458
 
1419
1459
  ```js
1420
1460
  const controller = new AbortController();
@@ -1430,15 +1470,15 @@ axios
1430
1470
  controller.abort();
1431
1471
  ```
1432
1472
 
1433
- ### CancelToken `👎deprecated`
1473
+ ### CancelToken (deprecated)
1434
1474
 
1435
1475
  You can also cancel a request using a _CancelToken_.
1436
1476
 
1437
1477
  > The axios cancel token API is based on the withdrawn [cancellable promises proposal](https://github.com/tc39/proposal-cancelable-promises).
1438
1478
 
1439
- > This API is deprecated since v0.22.0 and shouldn't be used in new projects
1479
+ > This API is deprecated since v0.22.0 and should not be used in new projects.
1440
1480
 
1441
- You can create a cancel token using the `CancelToken.source` factory as shown below:
1481
+ Create a cancel token with the `CancelToken.source` factory:
1442
1482
 
1443
1483
  ```js
1444
1484
  const CancelToken = axios.CancelToken;
@@ -1470,7 +1510,7 @@ axios.post(
1470
1510
  source.cancel('Operation canceled by the user.');
1471
1511
  ```
1472
1512
 
1473
- You can also create a cancel token by passing an executor function to the `CancelToken` constructor:
1513
+ You can also pass an executor function to the `CancelToken` constructor:
1474
1514
 
1475
1515
  ```js
1476
1516
  const CancelToken = axios.CancelToken;
@@ -1487,8 +1527,8 @@ axios.get('/user/12345', {
1487
1527
  cancel();
1488
1528
  ```
1489
1529
 
1490
- > **Note:** you can cancel several requests with the same cancel token/abort controller.
1491
- > If a cancellation token is already cancelled at the moment of starting an Axios request, then the request is cancelled immediately, without any attempts to make a real request.
1530
+ > Note: You can cancel several requests with the same cancel token or abort controller.
1531
+ > If a cancellation token is already cancelled when an Axios request starts, Axios cancels the request immediately without making a real request.
1492
1532
 
1493
1533
  > During the transition period, you can use both cancellation APIs, even for the same request:
1494
1534
 
@@ -1496,7 +1536,7 @@ cancel();
1496
1536
 
1497
1537
  ### URLSearchParams
1498
1538
 
1499
- By default, axios serializes JavaScript objects to `JSON`. To send data in the [`application/x-www-form-urlencoded`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) format instead, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API, which is [supported](http://www.caniuse.com/#feat=urlsearchparams) in the vast majority of browsers, and [Node](https://nodejs.org/api/url.html#url_class_urlsearchparams) starting with v10 (released in 2018).
1539
+ By default, axios serializes JavaScript objects to `JSON`. To send data as [`application/x-www-form-urlencoded`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST), use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API. It works in most browsers and in [Node](https://nodejs.org/api/url.html#url_class_urlsearchparams) v10 and later.
1500
1540
 
1501
1541
  ```js
1502
1542
  const params = new URLSearchParams({ foo: 'bar' });
@@ -1504,9 +1544,9 @@ params.append('extraparam', 'value');
1504
1544
  axios.post('/foo', params);
1505
1545
  ```
1506
1546
 
1507
- ### Query string (Older browsers)
1547
+ ### Query string (older browsers)
1508
1548
 
1509
- For compatibility with very old browsers, there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment).
1549
+ For very old browsers, use a [polyfill](https://github.com/WebReflection/url-search-params) and make sure it patches the global environment.
1510
1550
 
1511
1551
  Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library:
1512
1552
 
@@ -1515,7 +1555,7 @@ const qs = require('qs');
1515
1555
  axios.post('/foo', qs.stringify({ bar: 123 }));
1516
1556
  ```
1517
1557
 
1518
- Or in another way (ES6),
1558
+ With ES modules:
1519
1559
 
1520
1560
  ```js
1521
1561
  import qs from 'qs';
@@ -1531,7 +1571,7 @@ axios(options);
1531
1571
 
1532
1572
  ### Older Node.js versions
1533
1573
 
1534
- For older Node.js engines, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:
1574
+ For older Node.js engines, use the [`querystring`](https://nodejs.org/api/querystring.html) module:
1535
1575
 
1536
1576
  ```js
1537
1577
  const querystring = require('querystring');
@@ -1540,11 +1580,11 @@ axios.post('https://something.com/', querystring.stringify({ foo: 'bar' }));
1540
1580
 
1541
1581
  You can also use the [`qs`](https://github.com/ljharb/qs) library.
1542
1582
 
1543
- > **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.
1583
+ > 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.
1544
1584
 
1545
- ### 🆕 Automatic serialization to URLSearchParams
1585
+ ### Automatic serialization to URLSearchParams
1546
1586
 
1547
- Axios will automatically serialize the data object to urlencoded format if the content-type header is set to "application/x-www-form-urlencoded".
1587
+ Axios automatically serializes the data object to urlencoded format if the content-type header is set to "application/x-www-form-urlencoded".
1548
1588
 
1549
1589
  ```js
1550
1590
  const data = {
@@ -1562,7 +1602,7 @@ await axios.postForm('https://postman-echo.com/post', data, {
1562
1602
  });
1563
1603
  ```
1564
1604
 
1565
- The server will handle it as:
1605
+ The server receives these fields:
1566
1606
 
1567
1607
  ```js
1568
1608
  {
@@ -1579,7 +1619,7 @@ The server will handle it as:
1579
1619
  }
1580
1620
  ```
1581
1621
 
1582
- If your backend body-parser (like `body-parser` of `express.js`) supports nested objects decoding, you will get the same object on the server-side automatically
1622
+ If your backend body parser, such as `body-parser` for `express.js`, supports nested object decoding, the server receives the same object structure:
1583
1623
 
1584
1624
  ```js
1585
1625
  const app = express();
@@ -1598,8 +1638,8 @@ server = app.listen(3000);
1598
1638
 
1599
1639
  ### FormData
1600
1640
 
1601
- To send the data as a `multipart/form-data` you need to pass a formData instance as a payload.
1602
- Setting the `Content-Type` header is not required as Axios guesses it based on the payload type.
1641
+ To send data as `multipart/form-data`, pass a FormData instance as the payload.
1642
+ You do not need to set the `Content-Type` header. Axios detects it from the payload type.
1603
1643
 
1604
1644
  ```js
1605
1645
  const formData = new FormData();
@@ -1608,7 +1648,7 @@ formData.append('foo', 'bar');
1608
1648
  axios.post('https://httpbin.org/post', formData);
1609
1649
  ```
1610
1650
 
1611
- In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows:
1651
+ In node.js, use the [`form-data`](https://github.com/form-data/form-data) library:
1612
1652
 
1613
1653
  ```js
1614
1654
  const FormData = require('form-data');
@@ -1623,12 +1663,12 @@ axios.post('https://example.com', form);
1623
1663
 
1624
1664
  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.
1625
1665
 
1626
- ### 🆕 Automatic serialization to FormData
1666
+ ### Automatic serialization to FormData
1627
1667
 
1628
- Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData object if the request `Content-Type`
1668
+ Since `v0.27.0`, Axios can serialize an object to FormData if the request `Content-Type`
1629
1669
  header is set to `multipart/form-data`.
1630
1670
 
1631
- The following request will submit the data in a FormData format (Browser & Node.js):
1671
+ This request submits data as FormData in browsers and Node.js:
1632
1672
 
1633
1673
  ```js
1634
1674
  import axios from 'axios';
@@ -1646,10 +1686,9 @@ axios
1646
1686
  .then(({ data }) => console.log(data));
1647
1687
  ```
1648
1688
 
1649
- In the `node.js` build, the ([`form-data`](https://github.com/form-data/form-data)) polyfill is used by default.
1689
+ The Node.js build uses the [`form-data`](https://github.com/form-data/form-data) polyfill by default.
1650
1690
 
1651
- You can overload the FormData class by setting the `env.FormData` config variable,
1652
- but you probably won't need it in most cases:
1691
+ You can override the FormData class with the `env.FormData` config option, but most applications do not need this:
1653
1692
 
1654
1693
  ```js
1655
1694
  const axios = require('axios');
@@ -1668,30 +1707,30 @@ axios
1668
1707
  .then(({ data }) => console.log(data));
1669
1708
  ```
1670
1709
 
1671
- Axios FormData serializer supports some special endings to perform the following operations:
1710
+ The Axios FormData serializer supports these special endings:
1672
1711
 
1673
1712
  - `{}` - serialize the value with JSON.stringify
1674
1713
  - `[]` - unwrap the array-like object as separate fields with the same key
1675
1714
 
1676
- > **Note**: unwrap/expand operation will be used by default on arrays and FileList objects
1715
+ > Note: Arrays and FileList objects are unwrapped by default.
1677
1716
 
1678
1717
  FormData serializer supports additional options via `config.formSerializer: object` property to handle rare cases:
1679
1718
 
1680
- - `visitor: Function` - user-defined visitor function that will be called recursively to serialize the data object
1719
+ - `visitor: Function` - user-defined visitor function that Axios calls recursively to serialize the data object
1681
1720
  to a `FormData` object by following custom rules.
1682
1721
 
1683
1722
  - `dots: boolean = false` - use dot notation instead of brackets to serialize arrays and objects;
1684
1723
 
1685
1724
  - `metaTokens: boolean = true` - add the special ending (e.g `user{}: '{"name": "John"}'`) in the FormData key.
1686
- The back-end body-parser could potentially use this meta-information to automatically parse the value as JSON.
1725
+ A backend body parser can use this meta-information to parse the value as JSON.
1687
1726
 
1688
- - `indexes: null|false|true = false` - controls how indexes will be added to unwrapped keys of `flat` array-like objects.
1727
+ - `indexes: null|false|true = false` - controls how Axios adds indexes to unwrapped keys of `flat` array-like objects.
1689
1728
  - `null` - don't add brackets (`arr: 1`, `arr: 2`, `arr: 3`)
1690
1729
  - `false`(default) - add empty brackets (`arr[]: 1`, `arr[]: 2`, `arr[]: 3`)
1691
1730
  - `true` - add brackets with indexes (`arr[0]: 1`, `arr[1]: 2`, `arr[2]: 3`)
1692
1731
  - `maxDepth: number = 100` - maximum object nesting depth the serializer will recurse into. If the
1693
1732
  input object exceeds this depth, an `AxiosError` with `code: 'ERR_FORM_DATA_DEPTH_EXCEEDED'` is
1694
- thrown instead of overflowing the call stack. This protects server-side applications from DoS
1733
+ thrown instead of overflowing the call stack. This protects server applications from DoS
1695
1734
  attacks via deeply nested payloads. Set to `Infinity` to disable the limit and restore pre-fix behaviour.
1696
1735
 
1697
1736
  ```js
@@ -1702,7 +1741,7 @@ axios.postForm('/api', data, { formSerializer: { maxDepth: 200 } });
1702
1741
  axios.get('/api', { params: data, paramsSerializer: { maxDepth: 200 } });
1703
1742
  ```
1704
1743
 
1705
- Let's say we have an object like this one:
1744
+ Given this object:
1706
1745
 
1707
1746
  ```js
1708
1747
  const obj = {
@@ -1717,7 +1756,7 @@ const obj = {
1717
1756
  };
1718
1757
  ```
1719
1758
 
1720
- The following steps will be executed by the Axios serializer internally:
1759
+ The Axios serializer appends these fields:
1721
1760
 
1722
1761
  ```js
1723
1762
  const formData = new FormData();
@@ -1735,12 +1774,11 @@ formData.append('users[1][surname]', 'Anderson');
1735
1774
  formData.append('obj2{}', '[{"x":1}]');
1736
1775
  ```
1737
1776
 
1738
- Axios supports the following shortcut methods: `postForm`, `putForm`, `patchForm`
1739
- which are just the corresponding http methods with the `Content-Type` header preset to `multipart/form-data`.
1777
+ Axios supports `postForm`, `putForm`, and `patchForm` as shortcuts for the matching HTTP methods with the `Content-Type` header preset to `multipart/form-data`.
1740
1778
 
1741
- ## Files Posting
1779
+ ## Posting files
1742
1780
 
1743
- You can easily submit a single file:
1781
+ Submit a single file:
1744
1782
 
1745
1783
  ```js
1746
1784
  await axios.postForm('https://httpbin.org/post', {
@@ -1763,9 +1801,9 @@ await axios.postForm('https://httpbin.org/post', {
1763
1801
  await axios.postForm('https://httpbin.org/post', document.querySelector('#fileInput').files);
1764
1802
  ```
1765
1803
 
1766
- All files will be sent with the same field names: `files[]`.
1804
+ Axios sends all files with the same field name: `files[]`.
1767
1805
 
1768
- ## 🆕 HTML Form Posting (browser)
1806
+ ## HTML form posting (browser)
1769
1807
 
1770
1808
  Pass an HTML Form element as a payload to submit it as `multipart/form-data` content.
1771
1809
 
@@ -1803,7 +1841,7 @@ For example, the Form
1803
1841
  </form>
1804
1842
  ```
1805
1843
 
1806
- will be submitted as the following JSON object:
1844
+ submits this JSON object:
1807
1845
 
1808
1846
  ```js
1809
1847
  {
@@ -1825,10 +1863,10 @@ will be submitted as the following JSON object:
1825
1863
 
1826
1864
  Sending `Blobs`/`Files` as JSON (`base64`) is not currently supported.
1827
1865
 
1828
- ## 🆕 Progress capturing
1866
+ ## Progress capturing
1829
1867
 
1830
- Axios supports both browser and node environments to capture request upload/download progress.
1831
- The frequency of progress events is forced to be limited to `3` times per second.
1868
+ Axios can capture request upload and download progress in browsers and Node.js.
1869
+ Progress events are limited to `3` times per second.
1832
1870
 
1833
1871
  ```js
1834
1872
  await axios.post(url, data, {
@@ -1874,14 +1912,14 @@ const { data } = await axios.post(SERVER_URL, readableStream, {
1874
1912
  });
1875
1913
  ```
1876
1914
 
1877
- > **Note:**
1915
+ > Note:
1878
1916
  > Capturing FormData upload progress is not currently supported in node.js environments.
1879
1917
 
1880
- > **⚠️ Warning**
1881
- > It is recommended to disable redirects by setting maxRedirects: 0 to upload the stream in the **node.js** environment,
1882
- > as the follow-redirects package will buffer the entire stream in RAM without following the "backpressure" algorithm.
1918
+ > Warning:
1919
+ > Set `maxRedirects: 0` when uploading streams in node.js.
1920
+ > The follow-redirects package buffers the entire stream in RAM and does not follow the "backpressure" algorithm.
1883
1921
 
1884
- ## 🆕 Rate limiting
1922
+ ## Rate limiting
1885
1923
 
1886
1924
  Download and upload rate limits can only be set for the http adapter (node.js):
1887
1925
 
@@ -1895,25 +1933,24 @@ const { data } = await axios.post(LOCAL_SERVER_URL, myBuffer, {
1895
1933
  });
1896
1934
  ```
1897
1935
 
1898
- ## 🆕 AxiosHeaders
1936
+ ## AxiosHeaders
1899
1937
 
1900
- Axios has its own `AxiosHeaders` class to manipulate headers using a Map-like API that guarantees caseless work.
1901
- Although HTTP is case-insensitive in headers, Axios will retain the case of the original header for stylistic reasons
1902
- and as a workaround when servers mistakenly consider the header's case.
1903
- The old approach of directly manipulating the headers object is still available, but deprecated and not recommended for future usage.
1938
+ Axios includes an `AxiosHeaders` class for working with headers through a Map-like API.
1939
+ HTTP header names are case-insensitive, but Axios keeps the original header case for style and for servers that incorrectly depend on case.
1940
+ Directly manipulating the headers object still works, but it is deprecated.
1904
1941
 
1905
1942
  ### Working with headers
1906
1943
 
1907
- An AxiosHeaders object instance can contain different types of internal values. that control setting and merging logic.
1908
- The final headers object with string values is obtained by Axios by calling the `toJSON` method.
1944
+ An `AxiosHeaders` instance can contain several internal value types that control setting and merging.
1945
+ Axios gets the final headers object with string values by calling `toJSON`.
1909
1946
 
1910
1947
  > Note: By JSON here we mean an object consisting only of string values intended to be sent over the network.
1911
1948
 
1912
1949
  The header value can be one of the following types:
1913
1950
 
1914
- - `string` - normal string value that will be sent to the server
1951
+ - `string` - normal string value sent to the server
1915
1952
  - `null` - skip header when rendering to JSON
1916
- - `false` - skip header when rendering to JSON, additionally indicates that `set` method must be called with `rewrite` option set to `true`
1953
+ - `false` - skip header when rendering to JSON. Also indicates that the `set` method must be called with `rewrite` set to `true`
1917
1954
  to overwrite this value (Axios uses this internally to allow users to opt out of installing certain headers like `User-Agent` or `Content-Type`)
1918
1955
  - `undefined` - value is not set
1919
1956
 
@@ -1930,7 +1967,7 @@ axios.interceptors.request.use((request: InternalAxiosRequestConfig) => {
1930
1967
  'My-set-header2': 'my-set-value2',
1931
1968
  });
1932
1969
 
1933
- request.headers.set('User-Agent', false); // disable subsequent setting the header by Axios
1970
+ request.headers.set('User-Agent', false); // prevent Axios from setting this header later
1934
1971
 
1935
1972
  request.headers.setContentType('text/plain');
1936
1973
 
@@ -1998,7 +2035,7 @@ Constructs a new `AxiosHeaders` instance.
1998
2035
  constructor(headers?: RawAxiosHeaders | AxiosHeaders | string);
1999
2036
  ```
2000
2037
 
2001
- If the headers object is a string, it will be parsed as RAW HTTP headers.
2038
+ If the headers object is a string, Axios parses it as raw HTTP headers.
2002
2039
 
2003
2040
  ```js
2004
2041
  const headers = new AxiosHeaders(`
@@ -2029,7 +2066,7 @@ The `rewrite` argument controls the overwriting behavior:
2029
2066
  - `undefined` (default) - overwrite the header unless its value is set to `false`
2030
2067
  - `true` - rewrite anyway
2031
2068
 
2032
- The option can also accept a user-defined function that determines whether the value should be overwritten or not.
2069
+ The option can also accept a user-defined function that determines whether to overwrite the value.
2033
2070
 
2034
2071
  Returns `this`.
2035
2072
 
@@ -2093,7 +2130,7 @@ clear(matcher?: AxiosHeaderMatcher): boolean;
2093
2130
  ```
2094
2131
 
2095
2132
  Removes all headers.
2096
- Unlike the `delete` method matcher, this optional matcher will be used to match against the header name rather than the value.
2133
+ Unlike the `delete` method matcher, this optional matcher matches the header name rather than the value.
2097
2134
 
2098
2135
  ```ts
2099
2136
  const headers = new AxiosHeaders({
@@ -2137,17 +2174,18 @@ Returns `this`.
2137
2174
  concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
2138
2175
  ```
2139
2176
 
2140
- Merges the instance with targets into a new `AxiosHeaders` instance. If the target is a string, it will be parsed as RAW HTTP headers.
2177
+ Merges the instance with targets into a new `AxiosHeaders` instance. If the target is a string, Axios parses it as raw HTTP headers.
2141
2178
 
2142
2179
  Returns a new `AxiosHeaders` instance.
2143
2180
 
2144
2181
  ### AxiosHeaders#toJSON(asStrings?)
2145
2182
 
2146
2183
  ```
2147
- toJSON(asStrings?: boolean): RawAxiosHeaders;
2184
+ toJSON(asStrings: true): Record<string, string>;
2185
+ toJSON(asStrings?: false): Record<string, string | string[]>;
2148
2186
  ```
2149
2187
 
2150
- Resolve all internal header values into a new null prototype object.
2188
+ Resolves all internal header values into a new null prototype object.
2151
2189
  Set `asStrings` to true to resolve arrays as a string containing all elements, separated by commas.
2152
2190
 
2153
2191
  ### AxiosHeaders.from(thing?)
@@ -2157,7 +2195,7 @@ from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
2157
2195
  ```
2158
2196
 
2159
2197
  Returns a new `AxiosHeaders` instance created from the raw headers passed in,
2160
- or simply returns the given headers object if it's an `AxiosHeaders` instance.
2198
+ or returns the given headers object if it's already an `AxiosHeaders` instance.
2161
2199
 
2162
2200
  ### AxiosHeaders.concat(...targets)
2163
2201
 
@@ -2181,11 +2219,10 @@ The following shortcuts are available:
2181
2219
 
2182
2220
  - `setContentEncoding`, `getContentEncoding`, `hasContentEncoding`
2183
2221
 
2184
- ## 🔥 Fetch adapter
2222
+ ## Fetch adapter
2185
2223
 
2186
- Fetch adapter was introduced in `v1.7.0`. By default, it will be used if `xhr` and `http` adapters are not available in the build,
2187
- or not supported by the environment.
2188
- To use it by default, it must be selected explicitly:
2224
+ Axios introduced the fetch adapter in `v1.7.0`. By default, Axios uses it when the `xhr` and `http` adapters are not available in the build or not supported by the environment.
2225
+ To use it by default, select it explicitly:
2189
2226
 
2190
2227
  ```js
2191
2228
  const { data } = axios.get(url, {
@@ -2203,20 +2240,19 @@ const fetchAxios = axios.create({
2203
2240
  const { data } = fetchAxios.get(url);
2204
2241
  ```
2205
2242
 
2206
- The adapter supports the same functionality as the `xhr` adapter, **including upload and download progress capturing**.
2207
- Also, it supports additional response types such as `stream` and `formdata` (if supported by the environment).
2243
+ The adapter supports the same features as the `xhr` adapter, including upload and download progress capturing.
2244
+ It also supports response types such as `stream` and `formdata` when the environment supports them.
2208
2245
 
2209
- ### 🔥 Custom fetch
2246
+ ### Custom fetch
2210
2247
 
2211
- Starting from `v1.12.0`, you can customize the fetch adapter to use a custom fetch API instead of environment globals.
2212
- You can pass a custom `fetch` function, `Request`, and `Response` constructors via env config.
2213
- This can be helpful in case of custom environments & app frameworks.
2248
+ Since `v1.12.0`, you can configure the fetch adapter to use a custom fetch API instead of environment globals.
2249
+ Pass a custom `fetch` function, `Request`, and `Response` constructors through `env` config.
2250
+ This helps in custom environments and app frameworks.
2214
2251
 
2215
- Also, when using a custom fetch, you may need to set custom Request and Response too. If you don't set them, global objects will be used.
2216
- If your custom fetch api does not have these objects, and the globals are incompatible with a custom fetch,
2217
- you must disable their use inside the fetch adapter by passing null.
2252
+ When using a custom fetch, you may also need to set custom `Request` and `Response` constructors. If you do not set them, Axios uses the global objects.
2253
+ If your custom fetch API does not provide these objects and the globals are incompatible with it, pass `null` to disable them inside the fetch adapter.
2218
2254
 
2219
- > Note: Setting `Request` & `Response` to `null` will make it impossible for the fetch adapter to capture the upload & download progress.
2255
+ > Note: Setting `Request` and `Response` to `null` prevents the fetch adapter from capturing upload and download progress.
2220
2256
 
2221
2257
  Basic example:
2222
2258
 
@@ -2236,7 +2272,7 @@ const instance = axios.create({
2236
2272
  });
2237
2273
  ```
2238
2274
 
2239
- #### 🔥 Using with Tauri
2275
+ #### Using with Tauri
2240
2276
 
2241
2277
  A minimal example of setting up Axios for use in a [Tauri](https://tauri.app/plugin/http-client/) app with a platform fetch function that ignores CORS policy for requests.
2242
2278
 
@@ -2257,10 +2293,9 @@ const instance = axios.create({
2257
2293
  const { data } = await instance.get('https://google.com');
2258
2294
  ```
2259
2295
 
2260
- #### 🔥 Using with SvelteKit
2296
+ #### Using with SvelteKit
2261
2297
 
2262
- [SvelteKit](https://svelte.dev/docs/kit/web-standards#Fetch-APIs) framework has a custom implementation of the fetch function for server rendering (so called `load` functions), and also uses relative paths,
2263
- which makes it incompatible with the standard URL API. So, Axios must be configured to use the custom fetch API:
2298
+ [SvelteKit](https://svelte.dev/docs/kit/web-standards#Fetch-APIs) uses a custom fetch function for server rendering in `load` functions. It also uses relative paths, which are incompatible with the standard URL API. Configure Axios to use SvelteKit's custom fetch API:
2264
2299
 
2265
2300
  ```js
2266
2301
  export async function load({ fetch }) {
@@ -2277,13 +2312,13 @@ export async function load({ fetch }) {
2277
2312
  }
2278
2313
  ```
2279
2314
 
2280
- #### HTTP/2 Support
2315
+ #### HTTP/2 support
2281
2316
 
2282
- Axios supports HTTP/2 via the Node.js `http` adapter (introduced in v1.13.0).
2317
+ Axios supports HTTP/2 through the Node.js `http` adapter, introduced in v1.13.0.
2283
2318
 
2284
- This support depends on the runtime environment. Since Axios relies on Node.js APIs, HTTP/2 functionality is available in supported Node.js versions, but may not work in other environments (such as Bun or Deno).
2319
+ Support depends on the runtime environment. Axios relies on Node.js APIs, so HTTP/2 works in supported Node.js versions but may not work in other environments such as Bun or Deno.
2285
2320
 
2286
- Options like `httpVersion` and `http2Options` are adapter-specific and may not behave consistently across all environments.
2321
+ Options like `httpVersion` and `http2Options` are adapter-specific and may not behave the same way in every environment.
2287
2322
 
2288
2323
  Note: HTTP/2 redirects are currently not supported by the HTTP/2 adapter.
2289
2324
 
@@ -2305,7 +2340,7 @@ const { data, headers, status } = await axios.post('https://httpbin.org/post', f
2305
2340
 
2306
2341
  ## Semver
2307
2342
 
2308
- Since Axios has reached a `v.1.0.0` we will fully embrace semver as per the spec [here](https://semver.org/)
2343
+ Axios follows [semver](https://semver.org/) since `v1.0.0`.
2309
2344
 
2310
2345
  ## Promises
2311
2346
 
@@ -2330,10 +2365,10 @@ try {
2330
2365
  }
2331
2366
  ```
2332
2367
 
2333
- Because axios dual publishes with an ESM default export and a CJS `module.exports`, there are some caveats.
2334
- The recommended setting is to use `"moduleResolution": "node16"` (this is implied by `"module": "node16"`). Note that this requires TypeScript 4.7 or greater.
2335
- If use ESM, your settings should be fine.
2336
- If you compile TypeScript to CJS and you cant use `"moduleResolution": "node 16"`, you have to enable `esModuleInterop`.
2368
+ Because axios publishes an ESM default export and a CJS `module.exports`, TypeScript has a few caveats.
2369
+ The recommended setting is `"moduleResolution": "node16"`, which is implied by `"module": "node16"`. This requires TypeScript 4.7 or greater.
2370
+ If you use ESM, your settings should be fine.
2371
+ If you compile TypeScript to CJS and can't use `"moduleResolution": "node 16"`, enable `esModuleInterop`.
2337
2372
  If you use TypeScript to type check CJS JavaScript code, your only option is to use `"moduleResolution": "node16"`.
2338
2373
 
2339
2374
  You can also create a custom instance with typed interceptors:
@@ -2354,7 +2389,7 @@ apiClient.interceptors.request.use((config: InternalAxiosRequestConfig) => {
2354
2389
 
2355
2390
  ## Online one-click setup
2356
2391
 
2357
- You can use Gitpod, an online IDE(which is free for Open Source) for contributing or running the examples online.
2392
+ You can use Gitpod, a free online IDE for open source projects, to contribute or run the examples online.
2358
2393
 
2359
2394
  [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/main/examples/server.js)
2360
2395
 
@@ -2373,7 +2408,7 @@ npm rebuild husky && npx husky
2373
2408
 
2374
2409
  Run those two commands once per fresh checkout. You do **not** need to re-run them after every subsequent `npm install`.
2375
2410
 
2376
- Do not remove `ignore-scripts=true` from `.npmrc` to "fix" this that re-opens the lifecycle-script attack surface for every other package in the tree. All CI workflows already invoke npm with `--ignore-scripts`, so local behaviour matches CI.
2411
+ Do not remove `ignore-scripts=true` from `.npmrc` to "fix" this. That reopens the lifecycle-script attack surface for every other package in the tree. All CI workflows already invoke npm with `--ignore-scripts`, so local behaviour matches CI.
2377
2412
 
2378
2413
  ## Resources
2379
2414
 
@@ -2384,7 +2419,7 @@ Do not remove `ignore-scripts=true` from `.npmrc` to "fix" this — that re-open
2384
2419
 
2385
2420
  ## Credits
2386
2421
 
2387
- axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [AngularJS](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of AngularJS.
2422
+ axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) in [AngularJS](https://angularjs.org/). It provides a standalone `$http`-like service for use outside AngularJS.
2388
2423
 
2389
2424
  ## License
2390
2425