2016-02-09 66 views
0

get部分,我对console.log()进行了注释。正因为如此,我在屏幕上收到了相应的信息。但如果我取消注释,我会在控制台收到此消息,如[message],但没有消息输出到屏幕。这是为什么?我可以在路由处理程序中没有2 req.flash('error')吗?Can not console.log(req.flash(“error”))and render message同时

app.get("/login", function(req, res){ 
    // console.log(req.flash("error")) 
    res.render('login', { message: req.flash('error') }); 
}) 

app.post("/login", function(req, res, next){ 
    console.log("posted") 
    passport.authenticate("local",{ 
     successRedirect : "https://stackoverflow.com/users/" + req.body.username, 
     failureRedirect : "/login", 
     failureFlash : true 
    })(req, res, next) 
}) 

使用var flash = require("connect-flash");

回答

1

由于connect-flash包状态(link) IM,邮件被清除后使用,所以当你控制台登录一个(使用),它的清除,当你在路线称它为一次/中间件已经空了。

编辑:如果你想用一个闪光的消息,曾多次也许有可能将其存储在一些局部变量,那么这两个CONSOLE.LOG,并在响应中使用,但它只是一个猜测。我现在没有设置环境来检查它。

相关问题