Skip to content

Instantly share code, notes, and snippets.

View dbshoupe's full-sized avatar

Brandon dbshoupe

  • Dothan, Alabama
View GitHub Profile
@dbshoupe
dbshoupe / Http.js
Last active October 2, 2021 16:07
Wrapper class for Axios in a Vue project that uses interceptor to inject token (stored using Vuex) into header for each request.
import axios from 'axios';
import store from "@/data/state"
class Http {
constructor() {
let service = axios.create({});
service.interceptors.request.use((config) => {
config.headers.common['x-access-token'] = store.state.token
return config