mirror of
https://github.com/arthurfiorette/axios-cache-interceptor.git
synced 2025-12-08 17:36:16 +00:00
docs: updated readme example
This commit is contained in:
parent
0d4854db83
commit
aa83c24e18
12
README.md
12
README.md
@ -67,7 +67,7 @@ import { createCache, SessionCacheStorage } from 'axios-cache-interceptor';
|
|||||||
const api = axios.create();
|
const api = axios.create();
|
||||||
|
|
||||||
// Other axios instance with caching enabled
|
// Other axios instance with caching enabled
|
||||||
const cache = createCache(api, {
|
const cachedApi = createCache(api, {
|
||||||
// Store values on window.sessionStorage
|
// Store values on window.sessionStorage
|
||||||
storage: new SessionCacheStorage(),
|
storage: new SessionCacheStorage(),
|
||||||
|
|
||||||
@ -75,8 +75,14 @@ const cache = createCache(api, {
|
|||||||
interpretHeader: true
|
interpretHeader: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// Exactly the same as before
|
// Make a requests that's only cached if the response comes with success header
|
||||||
cache.get('http://example.com/');
|
cachedApi.get('http://example.com/', {
|
||||||
|
cache: {
|
||||||
|
cachePredicate: {
|
||||||
|
containsHeaders: ['success']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { createCache, SessionCacheStorage } from '../src/index';
|
|||||||
const api = axios.create();
|
const api = axios.create();
|
||||||
|
|
||||||
// Other axios instance with caching enabled
|
// Other axios instance with caching enabled
|
||||||
const cache = createCache(api, {
|
const cachedApi = createCache(api, {
|
||||||
// Store values on window.sessionStorage
|
// Store values on window.sessionStorage
|
||||||
storage: new SessionCacheStorage(),
|
storage: new SessionCacheStorage(),
|
||||||
|
|
||||||
@ -15,5 +15,11 @@ const cache = createCache(api, {
|
|||||||
interpretHeader: true
|
interpretHeader: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// Exactly the same as before
|
// Make a requests that's only cached if the response comes with success header
|
||||||
cache.get('http://example.com/');
|
cachedApi.get('http://example.com/', {
|
||||||
|
cache: {
|
||||||
|
cachePredicate: {
|
||||||
|
containsHeaders: ['success']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user