Calling Express Route internally from inside NodeJS

The ‘usual’ or ‘correct’ way to handle this would be to have the function you want to call broken out by itself, detached from any route definitions. Perhaps in its own module, but not necessarily. Then just call it wherever you need it. Like so: function updateSomething(thing) { return myDb.save(thing); } // elsewhere: router.put(‘/api/update/something/:withParam’, function(req, … Read more

on html.actionlink click go to previous page

Unless you’re tracking what the previous page is on the server, why not just use the browser’s internal history? In that case there wouldn’t be a need for server-side code. You could just use something like this: <a href=”https://stackoverflow.com/questions/18465895/javascript:void(0);” onclick=”history.go(-1);”>Back to Details</a> Or, separating the code from the markup: <a href=”https://stackoverflow.com/questions/18465895/javascript:void(0);” id=”backLink”>Back to Details</a> <script … Read more