mirror of
https://github.com/arthurfiorette/axios-cache-interceptor.git
synced 2025-12-08 17:36:16 +00:00
docs: updated sidebar and added dev mode section
This commit is contained in:
parent
2d779ec0da
commit
cc6523f00c
@ -1,26 +1,27 @@
|
|||||||
- Getting Started
|
- Getting Started
|
||||||
|
|
||||||
- [Homepage](/ 'Homepage')
|
- [Homepage](/ 'Homepage')
|
||||||
- [Try it out!](pages/try-it-out.md 'Try axios-cache-interceptor')
|
- [Try it out!](pages/try-it-out.md 'Try axios-cache-interceptor in your browser!')
|
||||||
- [Installing](pages/installing.md 'Installing')
|
- [Installing](pages/installing.md 'Installing')
|
||||||
- [Usage & Examples](pages/usage-examples.md 'Interceptor')
|
- [Usage & examples](pages/usage-examples.md 'Usage and examples')
|
||||||
- [Storages](pages/storages.md 'Custom storages')
|
- [Storages](pages/storages.md 'Custom storages')
|
||||||
|
|
||||||
- Cache Interceptor API
|
- Cache Interceptor API
|
||||||
|
|
||||||
- [Request ID](pages/request-id.md 'Request ID')
|
- [Request Id](pages/request-id.md 'Request Id')
|
||||||
- [Global configuration](pages/global-configuration.md 'Global configuration')
|
- [Global configuration](pages/global-configuration.md 'Global configuration')
|
||||||
- [Per request configuration](pages/per-request-configuration.md 'Per request configuration')
|
- [Per request configuration](pages/per-request-configuration.md 'Per request configuration')
|
||||||
- [Response object](pages/response-object.md 'Response object')
|
- [Response object](pages/response-object.md 'Response object')
|
||||||
|
|
||||||
- Extras
|
- Extras
|
||||||
|
|
||||||
- [Typescript Users](pages/typescript-users.md 'Typescript users')
|
- [Development mode](pages/development-mode.md 'Development mode')
|
||||||
|
- [Typescript users](pages/typescript-users.md 'Typescript users')
|
||||||
- [Compiled code](pages/compiled-code.md 'Compiled code')
|
- [Compiled code](pages/compiled-code.md 'Compiled code')
|
||||||
- [Comparison](pages/comparison.md 'Comparison')
|
- [Comparison](pages/comparison.md 'Comparison')
|
||||||
|
|
||||||
- Other
|
- Other
|
||||||
|
|
||||||
- [License](pages/license.md 'License')
|
- [License](pages/license.md 'License')
|
||||||
- [Contact & Security](pages/contact.md 'Contact & Security')
|
- [Contact & security](pages/contact.md 'Contact & security')
|
||||||
- [Changelog](pages/changelog.md 'Changelog')
|
- [Changelog](pages/changelog.md 'Changelog')
|
||||||
|
|||||||
48
docs/pages/development-mode.md
Normal file
48
docs/pages/development-mode.md
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# Development
|
||||||
|
|
||||||
|
For development, debug and testing purposes, you can opt to use the **Development mode**.
|
||||||
|
|
||||||
|
It brings some extra features to our built code, like the `debug` option, source maps,
|
||||||
|
fewer code and etc.
|
||||||
|
|
||||||
|
You can enable it basically by using `/dev` at the end of the import path.
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { setupCache } from 'axios-cache-interceptor/esm/dev';
|
||||||
|
const { setupCache } = require('axios-cache-interceptor/umd/dev');
|
||||||
|
|
||||||
|
// https://cdn.jsdelivr.net/npm/axios-cache-interceptor/umd/dev.js
|
||||||
|
const { setupCache } = window.AxiosCacheInterceptor;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Debug option
|
||||||
|
|
||||||
|
The debug option will print debug information in the console. It is good if you need to
|
||||||
|
trace any undesired behavior or issue.
|
||||||
|
|
||||||
|
You can enable it by setting `debug` to a function that receives an string.
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Will print debug info in the console.
|
||||||
|
setupCache(axios, {
|
||||||
|
debug: console.log
|
||||||
|
});
|
||||||
|
|
||||||
|
// own logger or whatever.
|
||||||
|
setupCache(axios, {
|
||||||
|
debug: (message) => {
|
||||||
|
// Etc
|
||||||
|
myCustomLogger.emit({
|
||||||
|
key: 'axios-cache-interceptor',
|
||||||
|
log: message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Disables debug.
|
||||||
|
setupCache(axios, {
|
||||||
|
debug: undefined
|
||||||
|
});
|
||||||
|
// or
|
||||||
|
axiosCacheInstance.debug = undefined;
|
||||||
|
```
|
||||||
@ -1,15 +1,4 @@
|
|||||||
[](https://github.com/arthurfiorette/axios-cache-interceptor/issues)
|
# Homepage
|
||||||
[](https://github.com/arthurfiorette/axios-cache-interceptor/stargazers)
|
|
||||||
[](https://github.com/arthurfiorette/axios-cache-interceptor/blob/main/LICENSE)
|
|
||||||
[](https://npm.runkit.com/axios-cache-interceptor)
|
|
||||||
[](https://codecov.io/gh/arthurfiorette/axios-cache-interceptor)
|
|
||||||
[](https://www.npmjs.com/package/axios-cache-interceptor)
|
|
||||||
[](https://bundlephobia.com/package/axios-cache-interceptor@latest)
|
|
||||||
[](https://packagephobia.com/result?p=axios-cache-interceptor@latest)
|
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
## What is this library?
|
|
||||||
|
|
||||||
This package is an interceptor for [axios](https://axios-http.com/) that adds caching
|
This package is an interceptor for [axios](https://axios-http.com/) that adds caching
|
||||||
capabilities to it. It is a simple, easy to use and powerful library.
|
capabilities to it. It is a simple, easy to use and powerful library.
|
||||||
|
|||||||
@ -11,26 +11,26 @@ to the same id with `{ url: 'https://a.com/b/' }`.
|
|||||||
Also, a custom id can be used to treat two requests as the same.
|
Also, a custom id can be used to treat two requests as the same.
|
||||||
|
|
||||||
```js #runkit
|
```js #runkit
|
||||||
const Axios = require('axios');
|
const axios = require('axios');
|
||||||
const { setupCache } = require('axios-cache-interceptor');
|
const { setupCache } = require('axios-cache-interceptor');
|
||||||
|
|
||||||
// Global
|
// Global
|
||||||
setupCache(Axios);
|
setupCache(axios);
|
||||||
|
|
||||||
const { id } = await Axios.get('https://jsonplaceholder.typicode.com/posts/1', {
|
const { id } = await axios.get('https://jsonplaceholder.typicode.com/posts/1', {
|
||||||
baseURL: 'baseURL',
|
baseURL: 'baseURL',
|
||||||
query: { name: 'value' }
|
query: { name: 'value' }
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Id 1: ' + id);
|
console.log('Id 1: ' + id);
|
||||||
console.log('Cache 1:', await Axios.storage.get(id));
|
console.log('Cache 1:', await axios.storage.get(id));
|
||||||
|
|
||||||
const { id: id2 } = await Axios.get('https://jsonplaceholder.typicode.com/posts/1', {
|
const { id: id2 } = await axios.get('https://jsonplaceholder.typicode.com/posts/1', {
|
||||||
id: 'my-overridden-id'
|
id: 'my-overridden-id'
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Id 2: ' + id2);
|
console.log('Id 2: ' + id2);
|
||||||
console.log('Cache 2:', await Axios.storage.get(id2));
|
console.log('Cache 2:', await axios.storage.get(id2));
|
||||||
```
|
```
|
||||||
|
|
||||||
The
|
The
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user