I am unable to render the updated task. Is it because I did not pass the updated task? Shouldn’t the DB update automatically? I am able to redirect but the task is not updated.
app.patch("/task/:id/edit", async (req, res) => {
const { id } = req.params
await Task.findByIdAndUpdate(id, req.body, { runValidators: true, new: true })
res.redirect("/task")
})
I think the task should have been updated
New contributor
Arion Dutta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.