首页 > 解决方案 > 请求失败,状态码 403 axios vue

问题描述

当程序被记录时,数据会毫无痛苦地列在屏幕上。但是,当我重新安装 f5 时,我收到 Request failed with status code 403 错误并且数据未列出。我使用的系统中的代码如下:

request({
  url: '/api/v1/login',
  method: 'post',
  data
}).then(response => {
  const token = response.data.token;
  if (token) {
    axios.defaults.headers.common['Authorization'] = 'Token ' + token;
  } else {
    axios.defaults.headers.common['Authorization'] = null;
  }
})

标签: vue.jstokenaxios

解决方案


推荐阅读