How to implement Update function in MERN app?

Good time of day.

Trying to understand the MERN stack, example applications found on github

On the basis of this repository is already sketched out his first app, with some additions and modifications, and when I tried to add Update feature, stuck... (get,add,delete implemented by)
March 19th 20 at 08:41
1 answer
March 19th 20 at 08:43
Solution
of react in the request body send the _id item that want to update

then in the router for example using Express
https://mongoosejs.com/docs/api.html#model_Model.f...

Item.findOneAndUpdate(
 {_id: req.params.id }, // search for item by id
 { $set: { name: req.params.name } } // change field name received in the request body of react
).then( () => {
 // all went well
 Res. json({ success: true })
} ) 
 .catch( err => {
 // all went very badly
 Res. json({ success: false })
} )

Find more questions by tags ReactNode.jsMongoDB