Last active
August 14, 2019 07:08
-
-
Save asule90/6c9d8dbf3440355800c03d0d1ba6db91 to your computer and use it in GitHub Desktop.
Setup cache and header for axios instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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