Monday 13 March 2017

Dynamically redirect back to the same url after requesting

How do we dynamically redirect back to the same page after delete request.


Request link:
The request link which appears in many pages.

<a href="/delete/id">delete</a>

route.js

router.get('/delete/:id', function (req, res, next) {
      // deleting logic here
      res.redirect('/to/requesting/page');
});

where /to/resquesting/page is the url to the page that has requested deletion:

  • If /delete/:id has been requested from Homepage, we would call res.redirect('/home');
  • If /delete/:id has been requested from Product, we would call res.redirect('/product);


via NERDYLIZARD

No comments:

Post a Comment