Skip to content

Instantly share code, notes, and snippets.

@vmalep
Created November 8, 2021 17:27
Show Gist options
  • Save vmalep/ab3521401cb77f1fccb553e86608857e to your computer and use it in GitHub Desktop.
Save vmalep/ab3521401cb77f1fccb553e86608857e to your computer and use it in GitHub Desktop.
app.put('/api/movies/:id', (req, res) => {
const movieId = req.params.id
const moviePropsToUpdate = req.body
connection.promise().query(
'UPDATE movies SET ? WHERE id = ?',
[moviePropsToUpdate, movieId],)
.then(result=>res.status(200).send('Movie updated successfully 🎉'))
.catch(err=>{
console.log(err)
res.status(500).send('Error updating a movie')
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment