我正在尝试通过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)
})
但是我的{}身体变得空虚。我正在获取标头和其他数据,但没有数据。