Advertisement
Guest User

Express Test 4 Put & Postman

a guest
Dec 3rd, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  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. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement