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