GET 请求不应包含正文。
将方法从“GET”更改为“POST”
Like so:
axios.request({
method: 'POST',
url: `http://localhost:4444/next/api`,
headers: {
'Authorization': token
},
data: {
next_swastik: 'lets add something here'
},
})
并更改你的 api 以期待帖子
app.post('/next/api', verifyToken, function(req, res) {
console.log(req.body);
});
or
改变data
财产给params
axios.request({
method: 'GET',
url: `http://localhost:4444/next/api`,
headers: {
'Authorization': token
},
params: {
next_swastik: 'lets add something here'
},
})
并更改 api 以注销参数
app.get('/next/api', verifyToken, function(req, res) {
console.log(req.params);
});
就像 @MaieonBrix 所说,确保您的标头包含您要发送的内容类型。