axios 1.12.1 → 1.13.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
@@ -1,14 +1,14 @@
1
1
 
2
- <h3 align="center"> 🥇 Gold sponsors <br> </h3> <table align="center" width="100%"><tr width="33.333333333333336%"><td align="center" width="33.333333333333336%"> <a href="https://dev.intra-mart.jp/?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <img width="48px" height="47px" src="https://axios-http.com/assets/sponsors/opencollective/948009b39c308b39f58c5d1245abd22512adc37b.png" alt="intra-mart"/> </a> <p align="center" title="[1ページ目] CookBook の記事 intra-mart Developer Portal ">[1ページ目] CookBook の記事 intra-mart Developer Portal</p> <p align="center"> <a href="https://dev.intra-mart.jp/?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>dev.intra-mart.jp</b></a> </p>
3
- </td><td align="center" width="33.333333333333336%"> <a href="https://stytch.com/?utm_source&#x3D;oss-sponsorship&amp;utm_medium&#x3D;paid_sponsorship&amp;utm_content&#x3D;website-link&amp;utm_campaign&#x3D;axios-http" style="padding: 10px; display: inline-block" target="_blank"> <picture> <source width="200px" height="38px" media="(prefers-color-scheme: dark)" srcset="https://axios-http.com/assets/sponsors/stytch_white.png"> <img width="200px" height="38px" src="https://axios-http.com/assets/sponsors/stytch.png" alt="Stytch"/> </picture> </a> <p align="center" title="API-first authentication, authorization, and fraud prevention">API-first authentication, authorization, and fraud prevention</p> <p align="center"> <a href="https://stytch.com/?utm_source&#x3D;oss-sponsorship&amp;utm_medium&#x3D;paid_sponsorship&amp;utm_content&#x3D;website-link&amp;utm_campaign&#x3D;axios-http" target="_blank"><b>Website</b></a> | <a href="https://stytch.com/docs?utm_source&#x3D;oss-sponsorship&amp;utm_medium&#x3D;paid_sponsorship&amp;utm_content&#x3D;docs-link&amp;utm_campaign&#x3D;axios-http" target="_blank"><b>Documentation</b></a> | <a href="https://github.com/stytchauth/stytch-node?utm_source&#x3D;oss-sponsorship&amp;utm_medium&#x3D;paid_sponsorship&amp;utm_content&#x3D;node-sdk&amp;utm_campaign&#x3D;axios-http" target="_blank"><b>Node.js</b></a> </p>
2
+ <h3 align="center"> 🥇 Gold sponsors <br> </h3> <table align="center" width="100%"><tr width="33.333333333333336%"><td align="center" width="33.333333333333336%"> <a href="https://stytch.com/?utm_source&#x3D;oss-sponsorship&amp;utm_medium&#x3D;paid_sponsorship&amp;utm_content&#x3D;website-link&amp;utm_campaign&#x3D;axios-http" style="padding: 10px; display: inline-block" target="_blank"> <picture> <source width="200px" height="38px" media="(prefers-color-scheme: dark)" srcset="https://axios-http.com/assets/sponsors/stytch_white.png"> <img width="200px" height="38px" src="https://axios-http.com/assets/sponsors/stytch.png" alt="Stytch"/> </picture> </a> <p align="center" title="API-first authentication, authorization, and fraud prevention">API-first authentication, authorization, and fraud prevention</p> <p align="center"> <a href="https://stytch.com/?utm_source&#x3D;oss-sponsorship&amp;utm_medium&#x3D;paid_sponsorship&amp;utm_content&#x3D;website-link&amp;utm_campaign&#x3D;axios-http" target="_blank"><b>Website</b></a> | <a href="https://stytch.com/docs?utm_source&#x3D;oss-sponsorship&amp;utm_medium&#x3D;paid_sponsorship&amp;utm_content&#x3D;docs-link&amp;utm_campaign&#x3D;axios-http" target="_blank"><b>Documentation</b></a> | <a href="https://github.com/stytchauth/stytch-node?utm_source&#x3D;oss-sponsorship&amp;utm_medium&#x3D;paid_sponsorship&amp;utm_content&#x3D;node-sdk&amp;utm_campaign&#x3D;axios-http" target="_blank"><b>Node.js</b></a> </p>
4
3
  </td><td align="center" width="33.333333333333336%"> <a href="https://www.principal.com/about-us?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <img width="133px" height="43px" src="https://axios-http.com/assets/sponsors/principal.svg" alt="Principal Financial Group"/> </a> <p align="center" title="We’re bound by one common purpose: to give you the financial tools, resources and information you need to live your best life.">We’re bound by one common purpose: to give you the financial tools, resources and information you ne...</p> <p align="center"> <a href="https://www.principal.com/about-us?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>www.principal.com</b></a> </p>
5
- </td></tr><tr width="33.333333333333336%"><td align="center" width="33.333333333333336%"> <a href="https://twicsy.com/buy-instagram-followers?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <img width="85px" height="70px" src="https://axios-http.com/assets/sponsors/opencollective/dfa9670ad5e66eea17315332453c7f4e3a3b5905.png" alt="Buy Instagram Followers Twicsy"/> </a> <p align="center" title="Buy real Instagram followers from Twicsy starting at only $2.97. Twicsy has been voted the best site to buy followers from the likes of US Magazine.">Buy real Instagram followers from Twicsy starting at only $2.97. Twicsy has been voted the best site...</p> <p align="center"> <a href="https://twicsy.com/buy-instagram-followers?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>twicsy.com</b></a> </p>
6
- </td><td align="center" width="33.333333333333336%"> <a href="https://www.descope.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;referral&amp;utm_campaign&#x3D;axios-oss-sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <picture> <source width="200px" height="52px" media="(prefers-color-scheme: dark)" srcset="https://axios-http.com/assets/sponsors/descope_white.png"> <img width="200px" height="52px" src="https://axios-http.com/assets/sponsors/descope.png" alt="Descope"/> </picture> </a> <p align="center" 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.">Hi, we&#x27;re Descope! We are building something in the authentication space for app developers and...</p> <p align="center"> <a href="https://www.descope.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;referral&amp;utm_campaign&#x3D;axios-oss-sponsorship" target="_blank"><b>Website</b></a> | <a href="https://docs.descope.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;referral&amp;utm_campaign&#x3D;axios-oss-sponsorship" target="_blank"><b>Docs</b></a> | <a href="https://www.descope.com/community?utm_source&#x3D;axios&amp;utm_medium&#x3D;referral&amp;utm_campaign&#x3D;axios-oss-sponsorship" target="_blank"><b>Community</b></a> </p>
4
+ </td><td align="center" width="33.333333333333336%"> <a href="https://twicsy.com/buy-instagram-followers?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <img width="85px" height="70px" src="https://axios-http.com/assets/sponsors/opencollective/dfa9670ad5e66eea17315332453c7f4e3a3b5905.png" alt="Buy Instagram Followers Twicsy"/> </a> <p align="center" title="Buy real Instagram followers from Twicsy starting at only $2.97. Twicsy has been voted the best site to buy followers from the likes of US Magazine.">Buy real Instagram followers from Twicsy starting at only $2.97. Twicsy has been voted the best site...</p> <p align="center"> <a href="https://twicsy.com/buy-instagram-followers?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>twicsy.com</b></a> </p>
5
+ </td></tr><tr width="33.333333333333336%"><td align="center" width="33.333333333333336%"> <a href="https://www.descope.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;referral&amp;utm_campaign&#x3D;axios-oss-sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <picture> <source width="200px" height="52px" media="(prefers-color-scheme: dark)" srcset="https://axios-http.com/assets/sponsors/descope_white.png"> <img width="200px" height="52px" src="https://axios-http.com/assets/sponsors/descope.png" alt="Descope"/> </picture> </a> <p align="center" 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.">Hi, we&#x27;re Descope! We are building something in the authentication space for app developers and...</p> <p align="center"> <a href="https://www.descope.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;referral&amp;utm_campaign&#x3D;axios-oss-sponsorship" target="_blank"><b>Website</b></a> | <a href="https://docs.descope.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;referral&amp;utm_campaign&#x3D;axios-oss-sponsorship" target="_blank"><b>Docs</b></a> | <a href="https://www.descope.com/community?utm_source&#x3D;axios&amp;utm_medium&#x3D;referral&amp;utm_campaign&#x3D;axios-oss-sponsorship" target="_blank"><b>Community</b></a> </p>
7
6
  </td><td align="center" width="33.333333333333336%"> <a href="https://route4me.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <picture> <source width="200px" height="51px" media="(prefers-color-scheme: dark)" srcset="https://axios-http.com/assets/sponsors/route4me_white.png"> <img width="200px" height="51px" src="https://axios-http.com/assets/sponsors/route4me.png" alt="Route4Me"/> </picture> </a> <p align="center" title="Best Route Planning And Route Optimization Software">Best Route Planning And Route Optimization Software</p> <p align="center"> <a href="https://route4me.com/platform/route-optimization-software?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>Explore</b></a> | <a href="https://route4me.com/platform/marketplace/pricing?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>Free Trial</b></a> | <a href="https://route4me.com/contact?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>Contact</b></a> </p>
8
- </td></tr><tr width="33.333333333333336%"><td align="center" width="33.333333333333336%"> <a href="https://buzzoid.com/buy-instagram-followers/?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <img width="62px" height="70px" src="https://axios-http.com/assets/sponsors/opencollective/e1625cb54e10ee40180c99d1495a462e9d6664a4.png" alt="Buzzoid - Buy Instagram Followers"/> </a> <p align="center" title="At Buzzoid, you can buy Instagram followers quickly, safely, and easily with just a few clicks. Rated world&#x27;s #1 IG service since 2012.">At Buzzoid, you can buy Instagram followers quickly, safely, and easily with just a few clicks. Rate...</p> <p align="center"> <a href="https://buzzoid.com/buy-instagram-followers/?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>buzzoid.com</b></a> </p>
9
- </td><td align="center" width="33.333333333333336%"> <a href="https://www.famety.net/?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <img width="70px" height="70px" src="https://axios-http.com/assets/sponsors/opencollective/56645c65d4bad0ab84265e02430d19d64afde927.png" alt="Famety - Buy Instagram Followers"/> </a> <p align="center" title="At Famety, you can grow your social media following quickly, safely, and easily with just a few clicks. Rated the world’s #1 social media service since 2013.">At Famety, you can grow your social media following quickly, safely, and easily with just a few clic...</p> <p align="center"> <a href="https://www.famety.net/?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>www.famety.net</b></a> </p>
7
+ </td><td align="center" width="33.333333333333336%"> <a href="https://buzzoid.com/buy-instagram-followers/?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <img width="62px" height="70px" src="https://axios-http.com/assets/sponsors/opencollective/e1625cb54e10ee40180c99d1495a462e9d6664a4.png" alt="Buzzoid - Buy Instagram Followers"/> </a> <p align="center" title="At Buzzoid, you can buy Instagram followers quickly, safely, and easily with just a few clicks. Rated world&#x27;s #1 IG service since 2012.">At Buzzoid, you can buy Instagram followers quickly, safely, and easily with just a few clicks. Rate...</p> <p align="center"> <a href="https://buzzoid.com/buy-instagram-followers/?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>buzzoid.com</b></a> </p>
8
+ </td></tr><tr width="33.333333333333336%"><td align="center" width="33.333333333333336%"> <a href="https://www.famety.net/?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <img width="70px" height="70px" src="https://axios-http.com/assets/sponsors/opencollective/56645c65d4bad0ab84265e02430d19d64afde927.png" alt="Famety - Buy Instagram Followers"/> </a> <p align="center" title="At Famety, you can grow your social media following quickly, safely, and easily with just a few clicks. Rated the world’s #1 social media service since 2013.">At Famety, you can grow your social media following quickly, safely, and easily with just a few clic...</p> <p align="center"> <a href="https://www.famety.net/?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>www.famety.net</b></a> </p>
10
9
  </td><td align="center" width="33.333333333333336%"> <a href="https://poprey.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <img width="70px" height="70px" src="https://axios-http.com/assets/sponsors/opencollective/e699ec99f7df3a203ddbc49d3c7712a907e628ea.png" alt="Poprey - Buy Instagram Likes"/> </a> <p align="center" title="Buy Instagram Likes">Buy Instagram Likes</p> <p align="center"> <a href="https://poprey.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>poprey.com</b></a> </p>
11
- </td></tr><tr width="33.333333333333336%"><td align="center" width="33.333333333333336%"> <a href="https://ssmarket.net/buy-youtube-subscribers?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <img width="70px" height="70px" src="https://axios-http.com/assets/sponsors/opencollective/0845614102b0c6602707ca2983de05a0098faad4.png" alt="Buy Youtube Subscribers"/> </a> <p align="center" title="SS Market offers professional social media services that rapidly increase your YouTube subscriber count, elevating your channel to a powerful position.">SS Market offers professional social media services that rapidly increase your YouTube subscriber co...</p> <p align="center"> <a href="https://ssmarket.net/buy-youtube-subscribers?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>ssmarket.net</b></a> </p>
10
+ </td><td align="center" width="33.333333333333336%"> <a href="https://requestly.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship" style="padding: 10px; display: inline-block" target="_blank"> <img width="71px" height="70px" src="https://axios-http.com/assets/sponsors/opencollective/16450b4dc0deb9dab5a511bf2bc8b8b4ac33412f.png" alt="Requestly"/> </a> <p align="center" title="A lightweight open-source API Development, Testing &amp; Mocking platform">A lightweight open-source API Development, Testing &amp; Mocking platform</p> <p align="center"> <a href="https://requestly.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship" target="_blank"><b>requestly.com</b></a> </p>
11
+ </td></tr><tr width="33.333333333333336%"><td align="center" width="33.333333333333336%"> <a href="https://opencollective.com/axios/contribute" target="_blank" >💜 Become a sponsor</a>
12
12
  </td><td align="center" width="33.333333333333336%"> <a href="https://opencollective.com/axios/contribute" target="_blank" >💜 Become a sponsor</a>
13
13
  </td><td align="center" width="33.333333333333336%"> <a href="https://opencollective.com/axios/contribute" target="_blank" >💜 Become a sponsor</a>
14
14
  </td></tr></table>
@@ -16,7 +16,7 @@
16
16
  <!--<div>marker</div>-->
17
17
  <br><br>
18
18
  <div align="center">
19
- <a href="https://axios-http.com"><img src="https://axios-http.com/assets/logo.svg" /></a><br>
19
+ <a href="https://axios-http.com"><img src="https://axios-http.com/assets/logo.svg" alt="Axios" /></a><br>
20
20
  </div>
21
21
 
22
22
  <p align="center">Promise based HTTP client for the browser and node.js</p>
@@ -39,6 +39,7 @@
39
39
  [![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios)
40
40
  [![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios)
41
41
  [![Known Vulnerabilities](https://snyk.io/test/npm/axios/badge.svg)](https://snyk.io/test/npm/axios)
42
+ [![Contributors](https://img.shields.io/github/contributors/axios/axios.svg?style=flat-square)](CONTRIBUTORS.md)
42
43
 
43
44
 
44
45
 
@@ -80,9 +81,13 @@
80
81
  - [Files Posting](#files-posting)
81
82
  - [HTML Form Posting](#-html-form-posting-browser)
82
83
  - [🆕 Progress capturing](#-progress-capturing)
83
- - [🆕 Rate limiting](#-progress-capturing)
84
+ - [🆕 Rate limiting](#-rate-limiting)
84
85
  - [🆕 AxiosHeaders](#-axiosheaders)
85
86
  - [🔥 Fetch adapter](#-fetch-adapter)
87
+ - [🔥 Custom fetch](#-custom-fetch)
88
+ - [🔥 Using with Tauri](#-using-with-tauri)
89
+ - [🔥 Using with SvelteKit](#-using-with-sveltekit-)
90
+ - [🔥 HTTP2](#-http2)
86
91
  - [Semver](#semver)
87
92
  - [Promises](#promises)
88
93
  - [TypeScript](#typescript)
@@ -92,21 +97,22 @@
92
97
 
93
98
  ## Features
94
99
 
95
- - Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser
96
- - Make [http](https://nodejs.org/api/http.html) requests from node.js
97
- - Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API
98
- - Intercept request and response
99
- - Transform request and response data
100
- - Cancel requests
101
- - Automatic transforms for [JSON](https://www.json.org/json-en.html) data
102
- - 🆕 Automatic data object serialization to `multipart/form-data` and `x-www-form-urlencoded` body encodings
103
- - Client side support for protecting against [XSRF](https://en.wikipedia.org/wiki/Cross-site_request_forgery)
100
+ - **Browser Requests:** Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) directly from the browser.
101
+ - **Node.js Requests:** Make [http](https://nodejs.org/api/http.html) requests from Node.js environments.
102
+ - **Promise-based:** Fully supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API for easier asynchronous code.
103
+ - **Interceptors:** Intercept requests and responses to add custom logic or transform data.
104
+ - **Data Transformation:** Transform request and response data automatically.
105
+ - **Request Cancellation:** Cancel requests using built-in mechanisms.
106
+ - **Automatic JSON Handling:** Automatically serializes and parses [JSON](https://www.json.org/json-en.html) data.
107
+ - **Form Serialization:** 🆕 Automatically serializes data objects to `multipart/form-data` or `x-www-form-urlencoded` formats.
108
+ - **XSRF Protection:** Client-side support to protect against [Cross-Site Request Forgery](https://en.wikipedia.org/wiki/Cross-site_request_forgery).
104
109
 
105
110
  ## Browser Support
106
111
 
107
- ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari_48x48.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/main/src/opera/opera_48x48.png) | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_48x48.png) |
108
- --- | --- | --- | --- | --- |
109
- Latest | Latest | Latest | Latest | Latest | 11 |
112
+ | Chrome | Firefox | Safari | Opera | Edge |
113
+ |:------:|:-------:|:------:|:-----:|:----:|
114
+ | ![Chrome browser logo](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_48x48.png) | ![Firefox browser logo](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_48x48.png) | ![Safari browser logo](https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari_48x48.png) | ![Opera browser logo](https://raw.githubusercontent.com/alrra/browser-logos/main/src/opera/opera_48x48.png) | ![Edge browser logo](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_48x48.png) |
115
+ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
110
116
 
111
117
  [![Browser Matrix](https://saucelabs.com/open_sauce/build_matrix/axios.svg)](https://saucelabs.com/u/axios)
112
118
 
@@ -196,7 +202,7 @@ Using unpkg CDN:
196
202
 
197
203
  ## Example
198
204
 
199
- > **Note**: CommonJS usage
205
+ > **Note**: CommonJS usage
200
206
  > In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()`, use the following approach:
201
207
 
202
208
  ```js
@@ -418,18 +424,18 @@ These are the available config options for making requests. Only the `url` is re
418
424
  params: {
419
425
  ID: 12345
420
426
  },
421
-
422
- // `paramsSerializer` is an optional config that allows you to customize serializing `params`.
427
+
428
+ // `paramsSerializer` is an optional config that allows you to customize serializing `params`.
423
429
  paramsSerializer: {
424
430
 
425
431
  // Custom encoder function which sends key/value pairs in an iterative fashion.
426
- encode?: (param: string): string => { /* Do custom operations here and return transformed string */ },
427
-
432
+ encode?: (param: string): string => { /* Do custom operations here and return transformed string */ },
433
+
428
434
  // Custom serializer function for the entire parameter. Allows user to mimic pre 1.x behaviour.
429
- serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ),
430
-
431
- // Configuration for formatting array indexes in the params.
432
- indexes: false // Three available options: (1) indexes: null (leads to no brackets), (2) (default) indexes: false (leads to empty brackets), (3) indexes: true (leads to brackets with indexes).
435
+ serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ),
436
+
437
+ // Configuration for formatting array indexes in the params.
438
+ indexes: false // Three available options: (1) indexes: null (leads to no brackets), (2) (default) indexes: false (leads to empty brackets), (3) indexes: true (leads to brackets with indexes).
433
439
  },
434
440
 
435
441
  // `data` is the data to be sent as the request body
@@ -491,7 +497,7 @@ These are the available config options for making requests. Only the `url` is re
491
497
 
492
498
  // `xsrfHeaderName` is the name of the http header that carries the xsrf token value
493
499
  xsrfHeaderName: 'X-XSRF-TOKEN', // default
494
-
500
+
495
501
  // `undefined` (default) - set XSRF header only for the same origin requests
496
502
  withXSRFToken: boolean | undefined | ((config: InternalAxiosRequestConfig) => boolean | undefined),
497
503
 
@@ -541,7 +547,7 @@ These are the available config options for making requests. Only the `url` is re
541
547
  // Only either `socketPath` or `proxy` can be specified.
542
548
  // If both are specified, `socketPath` is used.
543
549
  socketPath: null, // default
544
-
550
+
545
551
  // `transport` determines the transport method that will be used to make the request.
546
552
  // If defined, it will be used. Otherwise, if `maxRedirects` is 0,
547
553
  // the default `http` or `https` library will be used, depending on the protocol specified in `protocol`.
@@ -834,10 +840,10 @@ The general structure of axios errors is as follows:
834
840
  | -------- | ---------- |
835
841
  | message | A quick summary of the error message and the status it failed with. |
836
842
  | name | This defines where the error originated from. For axios, it will always be an 'AxiosError'. |
837
- | stack | Provides the stack trace of the error. |
843
+ | stack | Provides the stack trace of the error. |
838
844
  | config | An axios config object with specific instance configurations defined by the user from when the request was made |
839
845
  | code | Represents an axios identified error. The table below lists out specific definitions for internal axios error. |
840
- | status | HTTP response status code. See [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for common HTTP response status code meanings.
846
+ | status | HTTP response status code. See [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for common HTTP response status code meanings.
841
847
 
842
848
  Below is a list of potential axios identified error:
843
849
 
@@ -1282,7 +1288,7 @@ Sending `Blobs`/`Files` as JSON (`base64`) is not currently supported.
1282
1288
  Axios supports both browser and node environments to capture request upload/download progress.
1283
1289
  The frequency of progress events is forced to be limited to `3` times per second.
1284
1290
 
1285
- ```js
1291
+ ```js
1286
1292
  await axios.post(url, data, {
1287
1293
  onUploadProgress: function (axiosProgressEvent) {
1288
1294
  /*{
@@ -1301,13 +1307,13 @@ await axios.post(url, data, {
1301
1307
  loaded: number;
1302
1308
  total?: number;
1303
1309
  progress?: number;
1304
- bytes: number;
1310
+ bytes: number;
1305
1311
  estimated?: number;
1306
1312
  rate?: number; // download speed in bytes
1307
1313
  download: true; // download sign
1308
1314
  }*/
1309
1315
  }
1310
- });
1316
+ });
1311
1317
  ```
1312
1318
 
1313
1319
  You can also track stream upload/download progress in node.js:
@@ -1317,7 +1323,7 @@ const {data} = await axios.post(SERVER_URL, readableStream, {
1317
1323
  onUploadProgress: ({progress}) => {
1318
1324
  console.log((progress * 100).toFixed(2));
1319
1325
  },
1320
-
1326
+
1321
1327
  headers: {
1322
1328
  'Content-Length': contentLength
1323
1329
  },
@@ -1343,7 +1349,7 @@ const {data} = await axios.post(LOCAL_SERVER_URL, myBuffer, {
1343
1349
  onUploadProgress: ({progress, rate}) => {
1344
1350
  console.log(`Upload [${(progress*100).toFixed(2)}%]: ${(rate / 1024).toFixed(2)}KB/s`)
1345
1351
  },
1346
-
1352
+
1347
1353
  maxRate: [100 * 1024], // 100KB/s limit
1348
1354
  });
1349
1355
  ```
@@ -1381,13 +1387,13 @@ The headers object is always initialized inside interceptors and transformers:
1381
1387
  "My-set-header1": "my-set-value1",
1382
1388
  "My-set-header2": "my-set-value2"
1383
1389
  });
1384
-
1390
+
1385
1391
  request.headers.set('User-Agent', false); // disable subsequent setting the header by Axios
1386
1392
 
1387
1393
  request.headers.setContentType('text/plain');
1388
-
1394
+
1389
1395
  request.headers['My-set-header2'] = 'newValue' // direct access is deprecated
1390
-
1396
+
1391
1397
  return request;
1392
1398
  }
1393
1399
  );
@@ -1413,7 +1419,7 @@ for(const [header, value] of headers) {
1413
1419
 
1414
1420
  ### new AxiosHeaders(headers?)
1415
1421
 
1416
- Constructs a new `AxiosHeaders` instance.
1422
+ Constructs a new `AxiosHeaders` instance.
1417
1423
 
1418
1424
  ```
1419
1425
  constructor(headers?: RawAxiosHeaders | AxiosHeaders | string);
@@ -1468,7 +1474,7 @@ const headers = new AxiosHeaders({
1468
1474
  'Content-Type': 'multipart/form-data; boundary=Asrf456BGe4h'
1469
1475
  });
1470
1476
 
1471
- console.log(headers.get('Content-Type'));
1477
+ console.log(headers.get('Content-Type'));
1472
1478
  // multipart/form-data; boundary=Asrf456BGe4h
1473
1479
 
1474
1480
  console.log(headers.get('Content-Type', true)); // parse key-value pairs from a string separated with \s,;= delimiters:
@@ -1512,7 +1518,7 @@ Returns `true` if at least one header has been removed.
1512
1518
  clear(matcher?: AxiosHeaderMatcher): boolean;
1513
1519
  ```
1514
1520
 
1515
- Removes all headers.
1521
+ Removes all headers.
1516
1522
  Unlike the `delete` method matcher, this optional matcher will be used to match against the header name rather than the value.
1517
1523
 
1518
1524
  ```ts
@@ -1567,7 +1573,7 @@ Returns a new `AxiosHeaders` instance.
1567
1573
  toJSON(asStrings?: boolean): RawAxiosHeaders;
1568
1574
  ````
1569
1575
 
1570
- Resolve all internal headers values into a new null prototype object.
1576
+ Resolve all internal headers values into a new null prototype object.
1571
1577
  Set `asStrings` to true to resolve arrays as a string containing all elements, separated by commas.
1572
1578
 
1573
1579
  ### AxiosHeaders.from(thing?)
@@ -1623,9 +1629,108 @@ const fetchAxios = axios.create({
1623
1629
  const {data} = fetchAxios.get(url);
1624
1630
  ```
1625
1631
 
1626
- The adapter supports the same functionality as `xhr` adapter, **including upload and download progress capturing**.
1632
+ The adapter supports the same functionality as `xhr` adapter, **including upload and download progress capturing**.
1627
1633
  Also, it supports additional response types such as `stream` and `formdata` (if supported by the environment).
1628
1634
 
1635
+ ### 🔥 Custom fetch
1636
+
1637
+ Starting from `v1.12.0`, you can customize the fetch adapter to use a custom fetch API instead of environment globals.
1638
+ You can pass a custom `fetch` function, `Request`, and `Response` constructors via env config.
1639
+ This can be helpful in case of custom environments & app frameworks.
1640
+
1641
+ 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.
1642
+ If your custom fetch api does not have these objects, and the globals are incompatible with a custom fetch,
1643
+ you must disable their use inside the fetch adapter by passing null.
1644
+
1645
+ > Note: Setting `Request` & `Response` to `null` will make it impossible for the fetch adapter to capture the upload & download progress.
1646
+
1647
+ Basic example:
1648
+
1649
+ ```js
1650
+ import customFetchFunction from 'customFetchModule';
1651
+
1652
+ const instance = axios.create({
1653
+ adapter: 'fetch',
1654
+ onDownloadProgress(e) {
1655
+ console.log('downloadProgress', e);
1656
+ },
1657
+ env: {
1658
+ fetch: customFetchFunction,
1659
+ Request: null, // undefined -> use the global constructor
1660
+ Response: null
1661
+ }
1662
+ });
1663
+ ```
1664
+
1665
+ #### 🔥 Using with Tauri
1666
+
1667
+ 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.
1668
+
1669
+ ```js
1670
+ import { fetch } from "@tauri-apps/plugin-http";
1671
+ import axios from "axios";
1672
+
1673
+ const instance = axios.create({
1674
+ adapter: 'fetch',
1675
+ onDownloadProgress(e) {
1676
+ console.log('downloadProgress', e);
1677
+ },
1678
+ env: {
1679
+ fetch
1680
+ }
1681
+ });
1682
+
1683
+ const {data} = await instance.get("https://google.com");
1684
+ ```
1685
+
1686
+ #### 🔥 Using with SvelteKit
1687
+
1688
+ [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,
1689
+ which makes it incompatible with the standard URL API. So, Axios must be configured to use the custom fetch API:
1690
+
1691
+ ```js
1692
+ export async function load({ fetch }) {
1693
+ const {data: post} = await axios.get('https://jsonplaceholder.typicode.com/posts/1', {
1694
+ adapter: 'fetch',
1695
+ env: {
1696
+ fetch,
1697
+ Request: null,
1698
+ Response: null
1699
+ }
1700
+ });
1701
+
1702
+ return { post };
1703
+ }
1704
+ ```
1705
+
1706
+ ## 🔥 HTTP2
1707
+
1708
+ In version `1.13.0`, experimental `HTTP2` support was added to the `http` adapter.
1709
+ The `httpVersion` option is now available to select the protocol version used.
1710
+ Additional native options for the internal `session.request()` call can be passed via the `http2Options` config.
1711
+ This config also includes the custom `sessionTimeout` parameter, which defaults to `1000ms`.
1712
+
1713
+ ```js
1714
+ const form = new FormData();
1715
+
1716
+ form.append('foo', '123');
1717
+
1718
+ const {data, headers, status} = await axios.post('https://httpbin.org/post', form, {
1719
+ httpVersion: 2,
1720
+ http2Options: {
1721
+ // rejectUnauthorized: false,
1722
+ // sessionTimeout: 1000
1723
+ },
1724
+ onUploadProgress(e) {
1725
+ console.log('upload progress', e);
1726
+ },
1727
+ onDownloadProgress(e) {
1728
+ console.log('download progress', e);
1729
+ },
1730
+ responseType: 'arraybuffer'
1731
+ });
1732
+ ```
1733
+
1629
1734
  ## Semver
1630
1735
 
1631
1736
  Since Axios has reached a `v.1.0.0` we will fully embrace semver as per the spec [here](https://semver.org/)
@@ -1679,4 +1784,4 @@ axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/
1679
1784
 
1680
1785
  ## License
1681
1786
 
1682
- [MIT](LICENSE)
1787
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)