File "axios.js"
Full Path: /home/pulsehostuk9/public_html/invoicer.pulsehost.co.uk/resources/scripts/plugins/axios.js
File size: 607 bytes
MIME-type: text/plain
Charset: utf-8
import axios from 'axios'
import Ls from '@/scripts/services/ls.js'
window.Ls = Ls
window.axios = axios
axios.defaults.withCredentials = true
axios.defaults.headers.common = {
'X-Requested-With': 'XMLHttpRequest',
}
/**
* Interceptors
*/
axios.interceptors.request.use(function (config) {
// Pass selected company to header on all requests
const companyId = Ls.get('selectedCompany')
const authToken = Ls.get('auth.token')
if (authToken) {
config.headers.common.Authorization = authToken
}
if (companyId) {
config.headers.common['company'] = companyId
}
return config
})