Guest User

Untitled

a guest
Jul 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. router.put('/update/:word', (req, res, next) => {
  2. // const word = new Word ({
  3. // word: req.body.word,
  4. // annotation: req.body.annotation,
  5. // });
  6. const {
  7. word,
  8. annotation,
  9. } = req.body;
  10.  
  11. Word.updateOne({
  12. word: req.params.word,
  13. // annotation: req.params.annotation
  14. }).then(result => {
  15. if (result.nModified > 0) {
  16. res.status(200).json({
  17. message: "Update successful!"
  18. });
  19. } else {
  20. res.status(401).json({
  21. message: "Not authorised!"
  22. });
  23. }
  24. })
  25. .catch(error => {
  26. console.log(error);
  27. res.status(500).json({
  28. message: "Could not update word!"
  29. });
  30. })
  31. });
Add Comment
Please, Sign In to add comment