Skip to content

Instantly share code, notes, and snippets.

@alyson-b69
Created September 14, 2020 07:43
Show Gist options
  • Save alyson-b69/9d002626c1dc72660cc8ccdfe3d4a260 to your computer and use it in GitHub Desktop.
Save alyson-b69/9d002626c1dc72660cc8ccdfe3d4a260 to your computer and use it in GitHub Desktop.
Express 4 - Méthode PUT
app.put("/api/movies/:id", (req, res) => {
const idMovie = req.params.id;
const formData = req.body;
connection.query(
"UPDATE movie SET ? WHERE id = ?",
[formData, idMovie],
(err) => {
if (err) {
console.log(err);
res.status(500).send("Erreur lors de la modification d'un film");
} else {
res.sendStatus(200);
}
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment