我 正在 尝试 POST 到 终结 点 并 使用 与 用户 USERID 关联 的 集合 更新 用户 配置 文件 。 我 一直 收到 401 unathorized
错误
路由 器 :
router.post(`/newfixture/:id`, async (req, res) => {
let fixture = new Fixture({
id: req.body.id,
homeTeam: req.body.homeTeam,
awayTeam: req.body.awayTeam,
date: req.body.date,
time: req.body.time,
venue: req.body.venue,
});
// save the fixture to the user and return a response
fixture = await fixture.save({
id: req.body.id,
homeTeam: req.body.homeTeam,
awayTeam: req.body.awayTeam,
date: req.body.date,
time: req.body.time,
venue: req.body.venue,
});
if (!fixture) {
return res.status(404).send("The fixture cannot be created!");
}
res.send(fixture);
console.log("fixture created", fixture);
});
中 的 每 一 个
然后 打 电话 给 axios :
axios
.post(`${baseURL}users/fixtures/newfixture/${id}`, {
homeTeam: homeTeam,
awayTeam: awayTeam,
venue: venue,
date: date,
time: time,
})
.then(res => {
if (res.status === 200) {
console.log('🤣 🤣 🤣 🤣 🤣 FIXTURE PUT', userProfile);
} else {
console.log('🤣 🤣 🤣 🤣 🤣 NOPE ', userProfile);
}
});
格式
你 能 帮帮 我 吗 ?
1条答案
按热度按时间fquxozlt1#
我认为您的端点不正确
应该是