相关疑难解决方法(0)

未在axios请求中发送主体数据

我正在尝试通过axios请求将数据发送到我的后端脚本,但是主体看起来是空的。

这是前端发送的请求:

axios.request({
  method: 'GET',
  url: `http://localhost:4444/next/api`,
  headers: {
    'Authorization': token
  },
  data: {
    next_swastik: 'lets add something here'
  },

}).then((res)=>{  
  console.log("api call sucessfull",res);

}).catch((err)=>{
  console.log("api call unsucessfull",err);

  this.props.toggleLoading(false);
})
Run Code Online (Sandbox Code Playgroud)

这是一个后端:

app.get('/next/api', verifyToken, function(req, res) {
console.log(req.body);
Run Code Online (Sandbox Code Playgroud)

})

但是我的{}身体变得空虚。我正在获取标头和其他数据,但没有数据。

javascript node.js reactjs axios

4
推荐指数
2
解决办法
7522
查看次数

标签 统计

axios ×1

javascript ×1

node.js ×1

reactjs ×1