Guest User

Untitled

a guest
Mar 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. router.get('/:itemid', (req, res, next)=>{
  2. Photo.findOne({'_id': req.params.itemid})
  3. .then((photo)=>{
  4. res.render('update', {
  5. item: photo
  6. });
  7. }).catch((err)=>{
  8. if (err){
  9. console.log(err);
  10. }
  11. });
  12.  
  13. });
  14.  
  15. router.post('/:itemid', (req, res, next)=>{
  16. Photo.findOne({'_id': req.params.itemid})
  17. .then((photo)=>{
  18. var data = {
  19. destination: req.body.destination,
  20. description: req.body.description
  21. }
  22. photo.set(data);
  23. photo.save().then(()=>{
  24. res.redirect('/mylist');
  25. });
  26. }).catch((err)=>{
  27. if (err){
  28. console.log(err);
  29. }
  30. });
  31. });
Add Comment
Please, Sign In to add comment