请求头
axios.interceptors.request.use(function (config) {
// console.log(localStorage.getItem('admin_info'))
let token = ''
if(localStorage.getItem('admin_info') == null){
return config
}else{
token = JSON.parse(localStorage.getItem('admin_info')).token
}
config.headers['token'] = token;
return config
}, function (error) {
return Promise.reject(error)
})
body
axios.interceptors.request.use(function (config) {
// console.log(localStorage.getItem('admin_info'))
let token = ''
if(localStorage.getItem('admin_info') == null){
return config
}else{
token = JSON.parse(localStorage.getItem('admin_info')).token
}
console.log(token)
if(config.data == '' || config.data == null || config.data ==undefined){
if (token) {
config.params['token'] = token
}
return config
}else{
if (token) {
config.data['token'] = token
}
return config
}
}, function (error) {
return Promise.reject(error)
})