I have a problem with flash at views. I am using connect-flash.
there is my configuration
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('secret'));
app.use(express.session());
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
app.use(function(req, res, next){
res.locals.flash = req.flash
next()
})
here I set flash message at controller action
exports.new = function(req, res){
req.flash('info', 'test')
res.render("session/new", {
title: 'Log In!'
})
}
and then, when I am trying to use flash('info') at view, I am getting this error
req.flash() requires sessions
I am new to nodejs, so excuse me please if it's stupid question.
maybe you called req.session.destroy() before the flash-data is passed to res.locals?!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With