req.flash不是函数错误

时间:2017-01-26 06:08:57

标签: node.js express flash-message

下面是我注册用户的代码。在安装必要的模块之后。 express-flash-2和express-session。下面的代码给了我错误" req.flash不是函数"。我可以采取任何方式吗?

router.post('/register', function(req, res) {
  var db = firebase.database();
  var email = req.body.email;
  var name = req.body.name;
  var username = req.body.username;
  var password = req.body.password;

  if(email === "" || name === "" || username === "" || password === "") {
    req.flash('msg', 'All fields are required.'); 
    res.redirect('/signup');
  } else {
    console.log('register successfully');
  }

});

0 个答案:

没有答案