how to send a flash message with res.redirect('/') sails js
node.js, sails.js
Solution
Your code looks fine for the controller. In your view, you can access the flash message as `req.flash('message')`, so in an .ejs file for example it would be `<%- req.flash('message') %>`
Problem
How to send a flash message with `res.redirect('/')` in Sails? When i check some condition in a controller then I want to redirect to another url, passing along a flash message. I am new to Sails, so any help will be appreciated. Controller action: ``` module.exports ={ index: function (req, res) { if(req.param('key')){ req.flash('message', 'welcome key is present'); res.redirect('/view/'); } else { req.flash('message', 'welcome key is not present'); res.redirect('/'); } } } ``` Thanks in advance.