【发布时间】:2019-12-26 22:33:59
【问题描述】:
我有一个简单的 mern 应用程序。基本上有一个表格。提交后,后端 api 运行,更新 mongo db 中存在的用户文档。 我遇到的问题是,当我编写以下查询时,它会抛出一个令人讨厌的错误 Could not proxy request /api/auth/fb/register/patient from localhost:3000 to http://localhost:5000/.
router.post('/auth/fb/register/patient', (req,res) => {
User.updateOne({email: req.body.email}, { role: "patient"})
})
我认为路线错误或其他原因,但如果我运行查找查询而不是更新查询,它可以完美运行。以下是没有给出任何错误的查找查询:
router.post('/auth/fb/register/patient', (req,res) => {
User.findOne({email: req.body.email}).then(user => console.log(user))
})
有谁知道为什么更新特别不起作用?
【问题讨论】: