How to set up an update route in Express
I am building a MEVN stack CRUD app (Vue, Node, Express, MongoDB). I am attempting to set up the following Express route for my app... postRoutes.post('/update/:id', async(req, res)=> { const collection = await loadPostsCollection(); let id = req.params.id; let result = await collection.findOne(req.params.id) if (!result) { res.status(404).send("data is not found"); } else { result.title = req.body.title; result.body = req.body.body; result.updateOne(); } }); ..in order to update specific data based on the id of that data. After clicking the update button on the front end and triggering an upd
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.