Cache Fetch
Helper for caching fetch calls in localStorage
Installation
yarn add cached-fetch
or
npm install cached-fetch
Usage
; .../*** Cached fetch wrapper/helper* @param* @param* @param*/const url = 'API PATH';const options = headers: Accept: 'application/json' 'Content-Type': 'application/json' ; const response = ;// orconst response = ; return response;...
Offline handling (Great for PWA's)
Assuming the API call has been made already and your application has been setup for offline usage, you can use this helper to retrieve the saved data instead of using the cacheFetch
which will invalidate if cache time has elapsed.
; /* Will need proper implimentation based on application setup */let online = true;window;window;.../*** Cached fetch wrapper/helper* @param* @param* @param*/const url = 'API PATH';const options = headers: Accept: 'application/json' 'Content-Type': 'application/json' ; const response = online ? : ;// orconst response = online ? : ; return response;...
History
Discover the release history by heading on over to the releases page.
License
Unless stated otherwise all works are:
- Copyright © 2018+ Reme Le Hane
and licensed under: