GET请求不应包含主体。
将方法从“ GET”更改为“ POST”
像这样:
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);});要么
将
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所说的那样,请确保标头包含要发送的内容类型。



