Last active
October 2, 2021 16:07
-
-
Save dbshoupe/2c52a8145fbf811b8b7f1408f7be1858 to your computer and use it in GitHub Desktop.
Revisions
-
dbshoupe renamed this gist
Nov 14, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dbshoupe renamed this gist
Nov 14, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dbshoupe created this gist
Nov 14, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ 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 }) this.service = service; } redirectTo = (document, path) => { document.location = path } get(path) { return this.service.get(path) } patch(path, payload, callback) { return this.service.request({ method: 'PATCH', url: path, responseType: 'json', data: payload }).then((response) => callback(response.status, response.data)); } post(path, payload) { return this.service.request({ method: 'POST', url: path, responseType: 'json', data: payload }) } } export default new Http;