Guest User

Untitled

a guest
Nov 15th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. const express = require('express');
  2. const app = express();
  3. const connection = require('./conf');
  4. const port = 3000;
  5. const bodyParser = require('body-parser');
  6. app.use(bodyParser.json());
  7. app.use(bodyParser.urlencoded({
  8. extended: true,
  9. }));
  10.  
  11. app.put('/api/movie/:id', (req, res)=> {
  12. const idMovie = req.params.id;
  13. const formData = req.body;
  14.  
  15. connection.query('UPDATE movie SET ? WHERE id=?', [req.body, idMovie], err =>{
  16. if (err){
  17. console.log(err)
  18. } else {
  19. res.sendStatus(200);
  20. }
  21. })
  22. })
  23.  
  24. app.listen(port, (err) => {
  25. if (err) {
  26. throw new Error('Something bad happened...');
  27. }
  28.  
  29. console.log(`Server is listening on ${port}`);
  30. });
Add Comment
Please, Sign In to add comment