Vue.js 不确定如何在标题中键入正文
您好,我有点不确定如何做,或者如何将其安装到axios.post请求中,我找不到任何有意义的东西Vue.js 不确定如何在标题中键入正文,vue.js,Vue.js,您好,我有点不确定如何做,或者如何将其安装到axios.post请求中,我找不到任何有意义的东西 methods: { onUpdateProfileAdminChange: function() { this.axios.post('http://localhost:3000/admin/updateUser', {user: this.UpdateProfileAdmin}, { headers:
methods: {
onUpdateProfileAdminChange: function() {
this.axios.post('http://localhost:3000/admin/updateUser', {user: this.UpdateProfileAdmin}, {
headers: {
jwt: this.$cookies.get('jwt'),
},
body: {
user: this._id,
}
})
.then((res) => {
console.log(res)
}).catch(err => {
console.log(err.response.data)
});
},
the backend
router.post('/', async (req, res) => {
if(!req.headers.jwt || !req.body.user._id) {
res.status(503).json({
message: "missing values",
user: null
});
return;
}
我击中了身体。用户。\u id
但我不知道如何适应它
有什么帮助或建议吗?请查看axios文档,特别是关于如何设置请求的文档。作为对未来的建议,在询问之前,一定要检查文档以了解您正在使用的内容。如果有不清楚的地方,那就提问。这里的文档非常清楚:)@Gerken“在标题中键入正文”是什么意思?此外,Axios请求中没有
body
选项。我假设您希望在请求正文中发送user
,但您已经在第二个参数中传递了user
(正文参数应该在这里)。嘿,我发现问题是对象发送不正确,后端缺少一个“!”所以它已经修复了,我也忘记显示数据了我的错误