为了账号安全,请及时绑定邮箱和手机立即绑定

怎么把token加入到http头部啊?

怎么把token加入到http头部啊?

慕尼黑8549860 2018-09-24 16:43:42
怎么把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);
})


查看完整回答
反对 回复 2018-09-24
  • 1 回答
  • 0 关注
  • 4893 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号