怎么把token加入到http头部啊,在这里可以实现吗?
$axios.onRequest((config) => { if (!config.headers.common) { config.headers.common = {};
} config.headers.common.token = config.headers.common.Authorization || ''; return config;
});
1 回答
人到中年有点甜
TA贡献1895条经验 获得超7个赞
service.interceptors.request.use(config => { // Do something before request is sent if (store.getters.token) { config.headers['键'] = store.getters.token; } return config; }, error => { // Do something with request error //console.log(error); // for debug Promise.reject(error); })
添加回答
举报
0/150
提交
取消