diff --git a/README.md b/README.md index 70a2508..71381cb 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,7 @@ - [🆕 Progress capturing](#-progress-capturing) - [🆕 Rate limiting](#-progress-capturing) - [🆕 AxiosHeaders](#-axiosheaders) + - [🔥 Fetch adapter](#-fetch-adapter) - [Semver](#semver) - [Promises](#promises) - [TypeScript](#typescript) @@ -481,10 +482,13 @@ These are the available config options for making requests. Only the `url` is re withCredentials: false, // default // `adapter` allows custom handling of requests which makes testing easier. - // Return a promise and supply a valid response (see lib/adapters/README.md). + // Return a promise and supply a valid response (see lib/adapters/README.md) adapter: function (config) { /* ... */ }, + // Also, you can set the name of the built-in adapter, or provide an array with their names + // to choose the first available in the environment + adapter: 'xhr' // 'fetch' | 'http' | ['xhr', 'http', 'fetch'] // `auth` indicates that HTTP Basic auth should be used, and supplies credentials. // This will set an `Authorization` header, overwriting any existing @@ -1289,6 +1293,7 @@ Sending `Blobs`/`Files` as JSON (`base64`) is not currently supported. ## 🆕 Progress capturing Axios supports both browser and node environments to capture request upload/download progress. +The frequency of progress events is forced to be limited to `3` times per second. ```js await axios.post(url, data, { @@ -1609,6 +1614,30 @@ The following shortcuts are available: - `setContentEncoding`, `getContentEncoding`, `hasContentEncoding` +## 🔥 Fetch adapter + +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, +or not supported by the environment. +To use it by default, it must be selected explicitly: + +```js +const {data} = axios.get(url, { + adapter: 'fetch' // by default ['xhr', 'http', 'fetch'] +}) +``` + +You can create a separate instance for this: + +```js +const fetchAxios = axios.create({ + adapter: 'fetch' +}); + +const {data} = fetchAxios.get(url); +``` + +The adapter supports the same functionality as `xhr` adapter, **including upload and download progress capturing**. +Also, it supports additional response types such as `stream` and `formdata` (if supported by the environment). ## Semver