代码之家  ›  专栏  ›  技术社区  ›  SeaWarrior404

使用Axios的飞行前响应的HTTP状态代码400无效

  •  1
  • SeaWarrior404  · 技术社区  · 7 年前

    我的Axios调用如下:

         axios({
          method: 'get',
          url: DataURL,
          headers: {
            'Content-Type' : 'application/json',
            'Id': user.Id,
            'Name' : user.Name,
            'api-token' : user.access_token,
            'clientId' : 'web',
        },
        responseType: 'json',
      })
        .then((response) => {
          this.setState({ tableData: response.data });
        });
    

    然而,我得到了这个错误:

    我的API URL 飞行前的响应具有无效的HTTP状态代码400

    1 回复  |  直到 7 年前
        1
  •  1
  •   Thomas    7 年前

    我认为这是一个服务器端问题。如果您在后台使用node,则需要CORS作为中间件( https://www.npmjs.com/package/cors ).