Skip to content

Commit

Permalink
fix(docs): use getAdapder method to get the AxiosAdapter instead of…
Browse files Browse the repository at this point in the history
… passing the AxiosAdapterConfig
  • Loading branch information
HammzaHM authored Nov 18, 2024
1 parent 33e29d4 commit d3a1aea
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { cacheAdapterEnhancer, throttleAdapterEnhancer } from 'axios-extensions'
const http = axios.create({
baseURL: '/',
headers: { 'Cache-Control': 'no-cache' },
adapter: throttleAdapterEnhancer(cacheAdapterEnhancer(axios.defaults.adapter))
adapter: throttleAdapterEnhancer(cacheAdapterEnhancer(axios.getAdapter(axios.defaults.adapter)))
});
```

Expand Down Expand Up @@ -93,7 +93,7 @@ const http = axios.create({
baseURL: '/',
headers: { 'Cache-Control': 'no-cache' },
// cache will be enabled by default
adapter: cacheAdapterEnhancer(axios.defaults.adapter)
adapter: cacheAdapterEnhancer(axios.getAdapter(axios.defaults.adapter))
});

http.get('/users'); // make real http request
Expand All @@ -108,7 +108,7 @@ const http = axios.create({
baseURL: '/',
headers: { 'Cache-Control': 'no-cache' },
// disable the default cache and set the cache flag
adapter: cacheAdapterEnhancer(axios.defaults.adapter, { enabledByDefault: false, cacheFlag: 'useCache'})
adapter: cacheAdapterEnhancer(axios.getAdapter(axios.defaults.adapter), { enabledByDefault: false, cacheFlag: 'useCache'})
});

http.get('/users'); // default cache was disabled and then the real http request invoked
Expand Down Expand Up @@ -142,7 +142,7 @@ const http = axios.create({
baseURL: '/',
headers: { 'Cache-Control': 'no-cache' },
// disable the default cache
adapter: cacheAdapterEnhancer(axios.defaults.adapter, { enabledByDefault: false })
adapter: cacheAdapterEnhancer(axios.getAdapter(axios.defaults.adapter), { enabledByDefault: false })
});

http.get('/users', { cache: true }); // make the request cacheable(real http request made due to first request invoke)
Expand Down Expand Up @@ -181,7 +181,7 @@ Basically we recommend using the `throttleAdapterEnhancer` with `cacheAdapterEnh
Note that POST and other methods besides GET are not affected.

```js
throttleAdapterEnhancer(cacheAdapterEnhancer(axios.defaults.adapter))
throttleAdapterEnhancer(cacheAdapterEnhancer(axios.getAdapter(axios.defaults.adapter)))
```

Check [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) to learn more details about throttle and how it differs from debounce.
Expand All @@ -195,7 +195,7 @@ import { throttleAdapterEnhancer } from 'axios-extensions';
const http = axios.create({
baseURL: '/',
headers: { 'Cache-Control': 'no-cache' },
adapter: throttleAdapterEnhancer(axios.defaults.adapter, { threshold: 2 * 1000 })
adapter: throttleAdapterEnhancer(axios.getAdapter(axios.defaults.adapter), { threshold: 2 * 1000 })
});

http.get('/users'); // make real http request
Expand Down Expand Up @@ -229,7 +229,7 @@ import { retryAdapterEnhancer } from 'axios-extensions';
const http = axios.create({
baseURL: '/',
headers: { 'Cache-Control': 'no-cache' },
adapter: retryAdapterEnhancer(axios.defaults.adapter)
adapter: retryAdapterEnhancer(axios.getAdapter(axios.defaults.adapter))
});

// this request will retry two times if it failed
Expand Down

0 comments on commit d3a1aea

Please sign in to comment.