Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require("express");
- const app = express();
- const port = 3010;
- const connection = require("./conf");
- const bodyParser = require("body-parser");
- app.use(bodyParser.json());
- app.use(
- bodyParser.urlencoded({
- extended: true
- })
- );
- app.put("/api/movies/:id", (req, res) => {
- const idMovie = req.params.id;
- const formData = req.body;
- connection.query(
- "UPDATE movie SET ? WHERE id = ?",
- [req.body, idMovie],
- err => {
- if (err) {
- res.status(500).send("Erreur lors de la modification des données");
- } else {
- res.sendStatus(200);
- }
- }
- );
- });
- app.listen(port, err => {
- if (err) {
- throw new Error("Something bad happened ...");
- }
- console.log(`Server is listening on ${port}`);
- });
Add Comment
Please, Sign In to add comment