我正在尝试使用浏览器中的 PUT 请求并使用 Mongoose findByIdAndUpdate 通过表单更新我的 Mongo DB 中的文件。它执行并更新数据库中的文件。但是,PUT 请求会无限期地继续执行并导致超时错误。
我是 Node/JS 的新手 - 如果这是一个基本问题,我很抱歉。
An error occurred (InvalidParameterException) when calling the PutRetentionPolicy operation: Member must have length less than or equal to 512
浏览器:
app.put('/essays/:id', async(req, res) => {
const { id } = req.params;
const essay = await Essays.findByIdAndUpdate(id, {...req.body.essay });
console.log("updated")
})
这是我的控制台:
<form action="/essays/<%=essay._id%>?_method=PUT" method="POST" id="myForm">
<input type="hidden" id="essayBodyNew" name="essay[essayBody]" value=> </form>
当我在 Postman 上发出 PUT 请求时它也超时了。
答案 0 :(得分:1)
在 res.end('some message')
语句后调用 console
关闭请求