1.0.5 • Published 2 years ago

axios-storage-adapter v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

axios-storage-adapter

This is an Axios adapter designed to cache API calls. Cached data will be shared accross all the tabs in same domain, It will remove automatically when you close all the browser tabs. If you want to delete the cahce manually you can use below code CacheService.deleteData()

Install

npm install axios-storage-adapter

Usage

import Axios from "axios";
import { CacheService, StorageAdapter } from "axios-storage-adapter";

function App() {
  CacheService.setupDB("my-cache", "my-table", []);
  const request = Axios.create({
    adapter: StorageAdapter({
      cache: true,
    }) as any,
  });
  const loadData = () => {
    request.get("https://reqres.in/api/users?page=2").then((data) => {
      console.log(data);
    });
  };

  return (
    <>
      <button onClick={loadData}>Load</button>
    </>
  );
}

export default App;

Available setupDB parameters

parameterdescription
database nameoptional this is define your indexdDB database name
table nameoptional this is define your indexdDB table name
parametersoptional which ever parameter skipped from the url parameter, add it as array format

Support

If you are facing any issue, please contact via linkedin ( Libin Prasanth ).

Examples

Do you want to try axios-storage-adapter before use ?

Donate!

Like my Work! Donate

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago