Skip to content

Instantly share code, notes, and snippets.

@angelique-w
Created December 3, 2019 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelique-w/27ebb1b589710afc96f11ed71f86bfc1 to your computer and use it in GitHub Desktop.
Save angelique-w/27ebb1b589710afc96f11ed71f86bfc1 to your computer and use it in GitHub Desktop.
quête express 5
const express = require('express');
const app = express();
const port = 3000;
const connection = require('./conf');
const bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.delete('/api/movies/:id', (req, res) => {
const idMovie = req.params.id;
connection.query('DELETE FROM movie WHERE id = ?', [idMovie], err => {
if (err) {
console.log(err);
res.status(500).send("Erreur lors de la suppression d'un film");
} else {
res.sendStatus(200);
}
});
});
app.listen(port, (err) => {
if (err) {
throw new Error('Sometthing bad happened...');
}
console.log(`Server is listening on ${port}`);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment