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. It executes and the file updates in the database. However, the PUT request keeps executing indefinitely and is causing a timeout error.
I am new to Node/JS - and so apologies if this is a basic question.
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.
question from:
https://stackoverflow.com/questions/65874237/express-put-request-is-timing-out 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…