NodeJS flash message
connect-flash
To use flash message in your project, connect-flash is easy way
How to use
Add it to package.json
"connect-flash" : "~0.1.1"
install
npm install
Example
router.get('/', function(req, res, next) { res.render('index', { message: req.flash('info') }); }); router.get('/setmessage', function(req, res, next) { req.flash('info', 'Hello'); return res.redirect('/'); });
Access /setmessage, you set message key ‘info’, value ‘Hello’, and redirect root.
To retrieve it, req.flash(‘info’). we can set message to use in view.