From dd1fa41aa6ee499e1244fbc78e1d3b7b0f485b0b Mon Sep 17 00:00:00 2001 From: Hazork Date: Tue, 12 Oct 2021 20:02:39 -0300 Subject: [PATCH] docs: updated minimal example --- README.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f6b9099..7d5c76d 100644 --- a/README.md +++ b/README.md @@ -63,22 +63,19 @@ Axios Cache Interceptor ```ts import axios from 'axios'; -import { createCache, SessionCacheStorage } from 'axios-cache-interceptor'; +import { useCache, SessionCacheStorage } from 'axios-cache-interceptor'; -// Any custom axios instance -const api = axios.create(); - -// Other axios instance with caching enabled -const cachedApi = createCache(api, { - // Store values on window.sessionStorage - storage: new SessionCacheStorage(), - - // Use the max-age header to determine the cache expiration time - interpretHeader: true +// An axios instance with modified types +const api = useCache(axios.create(), { + /* options */ }); // Make a simple request, with caching support, to the api -const { data } = await cachedApi.get('https://api.example.com/'); +const resp1 = await api.get('https://api.example.com/'); +// resp1.cached = false + +const resp2 = await api.get('https://api.example.com/'); +// resp2.cached = true ```
@@ -178,7 +175,7 @@ After that, you can made your own requests normally. ## What we support -- [x] Cache concurrent requests +- [x] Concurrent requests - [x] Typescript support - [x] Unit tests - [x] Header interpretation