Skip to content

Instantly share code, notes, and snippets.

@asule90
Last active August 14, 2019 07:08
Show Gist options
  • Save asule90/6c9d8dbf3440355800c03d0d1ba6db91 to your computer and use it in GitHub Desktop.
Save asule90/6c9d8dbf3440355800c03d0d1ba6db91 to your computer and use it in GitHub Desktop.
Setup cache and header for axios instance
import axios from "axios";
import store from "@/store";
import {
cacheAdapterEnhancer,
throttleAdapterEnhancer
} from "axios-extensions";
const axios_instance = axios.create({
baseURL: your-api-url,
headers: {
'Authorization': "Bearer " + store.state.token
},
adapter: throttleAdapterEnhancer(
cacheAdapterEnhancer(axios.defaults.adapter)
)
});
export {axios_instance};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment