axios中为所有请求带上Token头

2020-04-23 17:36:50 浏览数 (1)

代码语言:javascript复制
axios.post('signToken', {
  "NickName": "xxxx",
  "Password": "xxxx",
  "RequestSign": "B858C5EEE7FD4D37C635FB55841ACA59"
}).then(res => {
  axios.defaults.headers.common['Authorization'] = res.headers.authorization
  //实例化Vue
  new Vue({
    el: '#app',
    router,
    components: {
      App
    },
    template: '<App/>'
  })
})

f获取完token再赋值,异步变为同步

0 人点赞