简体   繁体   English

express PUT 请求超时

[英]express PUT request is timing out

I am trying to update a file in my Mongo DB via a form using a PUT request in the browser and using Mongoose findByIdAndUpdate.我正在尝试使用浏览器中的 PUT 请求并使用 Mongoose findByIdAndUpdate 通过表单更新我的 Mongo DB 中的文件。 It executes and the file updates in the database.它执行并在数据库中更新文件。 However, the PUT request keeps executing indefinitely and is causing a timeout error.但是,PUT 请求会无限期地执行并导致超时错误。

I am new to Node/JS - and so apologies if this is a basic question.我是 Node/JS 的新手——如果这是一个基本问题,我深表歉意。

app.put('/essays/:id', async(req, res) => {
  const { id } = req.params;
  const essay = await Essays.findByIdAndUpdate(id, {...req.body.essay });
  console.log("updated")
})

Browser:浏览器:

<form action="/essays/<%=essay._id%>?_method=PUT" method="POST" id="myForm">
        <input type="hidden" id="essayBodyNew" name="essay[essayBody]" value=> </form>

Here is my console:这是我的控制台:

PUT /essays/600db52af8c50e195c159383?_method=PUT - - - - ms

It's also timing out when I make PUT requests on Postman.当我在 Postman 上发出 PUT 请求时,它也会超时。

call res.end('some message') after console statement to close requestconsole语句后调用res.end('some message')以关闭请求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM