// Add a response interceptor
HTTP.interceptors.response.use(function (response) {
return response
}, function(error) {
if (error.response.status === 401) {
store.dispatch('logout')
router.push('/login')
}
return Promise.reject(error.response.data)
})
axios.interceptors.request.use((value) => {
value.headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': '*',
'Access-Control-Allow-Headers': '*',
'Accept': 'application/json',
'Content-Type': 'application/json'
}
return value
})
Axios request/response and error/data interceptor