Sunday, 16 April 2017

Connect-flash message is not working for res.render("SomeView")

I am not able to use connect-flash package for res.render. My main aim is to display a flash message on rendering of a view.

I am able to make it work with a res.redirect("route") but not with the res.render("view") code. Is it by design ?

My code is shown as below

if(err){
      // Apparently res.render("register") didn't work with flash. But res.redirect("/register") worked.
        req.flash("error", err.message);   // Error occurs when the user is taken, password is empty etc.
        return res.redirect("/register");  // Short circut everything. Else the code below this would run as well and that would throw an error
    }



via harry

No comments:

Post a Comment