Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const app = express();
- const connection = require('./conf');
- const port = 3000;
- const bodyParser = require('body-parser');
- app.use(bodyParser.json());
- app.use(bodyParser.urlencoded({
- extended: true,
- }));
- app.put('/api/movie/: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){
- console.log(err)
- } 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