docs: updated readme

This commit is contained in:
Hazork 2021-09-13 12:25:05 -03:00
parent c48769a9c9
commit d8afd8a9e9
3 changed files with 14 additions and 17 deletions

View File

@ -1,3 +1,4 @@
/node_modules
/dist
/ignore
/ignore
/docs

View File

@ -36,6 +36,13 @@ Axios Cache Interceptor</h1>
target="_blank"
alt="License" /></a
></code>
<code
><a href="https://codecov.io/gh/arthurfiorette/axios-cache-adapter"
><img
src="https://codecov.io/gh/arthurfiorette/axios-cache-adapter/branch/main/graph/badge.svg"
target="_blank"
alt="Codecov" /></a
></code>
<code
><a href="https://www.npmjs.com/package/axios-cache-interceptor"
><img
@ -75,14 +82,8 @@ const cachedApi = createCache(api, {
interpretHeader: true
});
// Make a requests that's only cached if the response comes with success header
cachedApi.get('http://example.com/', {
cache: {
cachePredicate: {
containsHeaders: ['success']
}
}
});
// Make a simple request, with caching support, to the api
const { data } = await cachedApi.get('https://api.example.com/');
```
<br />

View File

@ -1,3 +1,4 @@
// @ts-nocheck
// Readme example
import axios from 'axios';
@ -15,11 +16,5 @@ const cachedApi = createCache(api, {
interpretHeader: true
});
// Make a requests that's only cached if the response comes with success header
cachedApi.get('http://example.com/', {
cache: {
cachePredicate: {
containsHeaders: ['success']
}
}
});
// Make a simple request, with caching support, to the api
const { data } = await cachedApi.get('https://api.example.com/');