Nuxt
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
771 B

// import $api from '../api/index' ;
// onRequest(config)
// onResponse(response)
// onError(err)
// onRequestError(err)
// onResponseError(err)
export default function ({ $axios,store, redirect }) {
// console.log($api);
// store.commit('user/setToken','dasdsad')
// let token = store.state.user.token;
// $axios.setToken(token, 'Bearer')
$axios.setHeader('Content-Type', 'application/json')
$axios.onRequest(config => {
console.log('Making request to ' + config.url)
})
$axios.onResponse(config => {
if(config.status == 200){
// return config.data;
}
// return config
})
$axios.onError(error => {
const code = parseInt(error.response && error.response.status)
if (code === 400) {
redirect('/400')
}
})
}