Siddhartha Chowdhury
Siddhartha Chowdhury

Reputation: 2732

Sails.js , calling route from Controller

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

Answers (1)

jelhan
jelhan

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

Related Questions