I know this is an old question, but I recently came across it trying to understand flash messages and patterns, so I hope this helps others in my situation. Considering the case of Express 4, the express flash module and the ejs template, here are 2 routes and a template that should launch you.
-, . app.all() /express-flash. baseurl/express-flash, set req.flash(type, message) baseurl/.
app.all('/express-flash', req, res ) {
req.flash('success', 'This is a flash message using the express-flash module.');
res.redirect(301, '/');
}
res.render() , baseurl/. req.flash(type) getter , success, , expressFlash.
app.get('/', req, res ) {
res.render('index', {expressFlash: req.flash('success') });
}
expressFlash, , index.ejs.
<p> Express-Flash Demo </p>
<% if ( expressFlash.length > 0 ) { %>
<p>Message: <%= expressFlash %> </p>
<% } %>
baseurl/express-flash. baseurl/ -. baseurl/ .