Reputation: 2732
js. I want to know if there is any way to call a route from a controller.
I use res.view('/path/to/ejs',{"msg":"something"});
to redirect to a .ejs file specifying the directory structure.
Instead in some cases I would like use something like
res.route('/url',
{
"msg":"something"
})
All I want to know is whether it is possible to achieve the same?
If YES then how?
Upvotes: 2
Views: 594
Reputation: 6338
res.view()
is not a redirect. Instead it renders the specified view. use res.redirect()
to send a 302 redirect. It makes no sense to pass locales to a redirect method since all modern browsers ignores response body on a redirect. Therefore res.redirect only accepts a url or path as parameter.
Upvotes: 1