Skip to content
This repository has been archived by the owner on May 7, 2019. It is now read-only.

PerchSecurity/axios-store-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

axios-store-plugin

💰 Axios plugin that uses store.js to cache GET requests.

Installing

Currently only availble via GitHub:

npm install usePF/axios-store-plugin

Usage

import axios from 'axios';
import storePlugin from 'axios-store-plugin';

const baseURL = `https://myapi.com/`;
const api = storePlugin(axios.create({ baseURL }));

// Use it like you would use Axios normally
const getNotifications = () => api.get('/notifications');

API

How to use and love the the axios store plugin.

axiosStore()

axiosStore(axiosInstance: axios)

The axiosStore funtion only accepts one argument, an instace of Axios.

Unwrapping data

Becuase the plugin only stores the data portion of the axios response, for consistency the data portion is always unwrapped and returned.