I use Express JS and I need functionality similar to Django's function reverse. Therefore, if I have a route, for example
app.get('/users/:id/:name', function(req, res) { } )
I would like to use a function like
reverse('/users/:id/:name', 15, 'John');
or even better
reverse('/users/:id/:name', { id : 15, name : 'John' });
which will give me url /users/15/John. Is there such a function? And if not, do you have any idea how to write such a function (taking into account the Express routing algorithm)?
source
share