Skip to content

Instantly share code, notes, and snippets.

@akorchev
Created August 9, 2017 15:14
Show Gist options
  • Save akorchev/988b951cbcf962d648389b52c4e5b0a8 to your computer and use it in GitHub Desktop.
Save akorchev/988b951cbcf962d648389b52c4e5b0a8 to your computer and use it in GitHub Desktop.
function update(req, res) {
const { id, name, saying } = req.body;
Hero.findOne({ id })
.then(hero => {
hero.name = name;
hero.saying = saying;
hero.save().then(() => res.json(hero))
})
.catch(err => {
res.status(500).send(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment