Skip to content

Instantly share code, notes, and snippets.

@wwwmarcos
Created January 28, 2018 01:07
Show Gist options
  • Save wwwmarcos/24ab0333984ea7718166567e9f70595a to your computer and use it in GitHub Desktop.
Save wwwmarcos/24ab0333984ea7718166567e9f70595a to your computer and use it in GitHub Desktop.
// services/http.js
import axios from 'axios'
import storage from './storage'
const transformRequest = (data, headers) => {
headers['x-api-token'] = storage.getToken()
return data
}
const configuredAxios = axios.create({
baseURL: 'https://dogs.com/',
headers: {'X-Custom-Header': 'foobar'},
transformRequest: [transformRequest]
})
export default configuredAxios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment