SHARE
TWEET

Express Test 4 Put & Postman

a guest Dec 3rd, 2019 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // listen to the url "/api/employees" with the verb POST
  2. app.put('/api/movies/:id', (req, res) => {
  3.  
  4.   // Get the data sent
  5.   const id = req.params.id;
  6.   const formData = req.body;
  7.  
  8.   // connection to the database, and insertion of the employee
  9.    connection.query('UPDATE movie SET ? WHERE id = ?', [formData, id], err => {
  10.     if (err) {
  11.       // If an error has occurred, then the user is informed of the error
  12.        console.log(err);
  13.       res.status(500).send("Error editing a movie");
  14.     } else {
  15.       // If everything was successful, we send an "ok" status.
  16.       res.sendStatus(200);
  17.     }
  18.   });
  19. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top