0.0.5 • Published 4 years ago

cachefetch_rn v0.0.5

Weekly downloads
8
License
GPL
Repository
github
Last release
4 years ago

cachefetch_rn

  • configurable cacheFetch for react-native,using AsyncStorage to cache
  • cacheFetch inherits the same API as fetch()

Usage

  • Install :npm install cacheFetch_RN
  • example:
import { AsyncStorage } from 'react-native';
import { clearFetchCache, makeCacheFetch } from 'cachefetch_rn';

const headersPopulator = (headers) => {
  //headers is a plain object
  console.log('before populate', headers);
  delete headers['Fc-Csrf'];
  delete headers['Cookie'];
  console.log('after populate', headers);
  return headers;
};
const cacheFetch = makeCacheFetch({
  AsyncStorage: AsyncStorage,
  fetch: global.fetch,
  headersPopulator: headersPopulator,
  logger: console,
});
global.fetch = cacheFetch; //optional,if you want all fetch to be cacheFetch 

API

  • clearFetchCache, clear all cache
  • makeCacheFetch(...),see code for detail
0.0.5

4 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago