Anis
Anis

Reputation: 1220

Stuck with req.flash is not a function error

followning is my app.js code and wherever i have put app.use(req.flash()); it give me this error i have tried different stacks for it buts its not working

var flash = require('connect-flash');

at this stage if i move routers down it give me some error of status code:1

app.use('/', index);
app.use(session({
  secret : 'abc',
  saveUninitialized : true,
  resave : true
}));
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());

Upvotes: 0

Views: 193

Answers (1)

Sourabh Kumar
Sourabh Kumar

Reputation: 94

app.use(function(req, res, next) {
res.locals.sucess_msg = req.flash('sucess_msg');
res.locals.error_msg = req.flash('error_msg');
res.locals.error = req.flash('error');
next();});

Upvotes: 1

Related Questions