3 works

Express Post Request to Edit Post

dashboard+ Project

Posted by @mishka #nodejs

router.post('/:id/edit', auth.requireLogin, (req, res, next) => {
  Post.findByIdAndUpdate(req.params.id, req.body, function(err, post) {
    if(err) { console.error(err) };

content_copyCopy to Clipboard

The url in the first line must be the same as the action in the edit form. Be aware that the findByIdAnd Update method erases previous data before replacing it.

>> Browse more code snippets