Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

378
Views
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
    }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This is the correct syntax for using req.flash with res.render:

req.flash('error', yourErrString);
res.render("register.ejs", {
   message: req.flash('error')
});
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!