79402254

Date: 2025-01-31 09:22:26
Score: 1.5
Natty:
Report link

I have found the issue. When you invoke console.log(req.flash('success_msg')); it clears/destroys the flash message. So if you would read it again, so another console.log(req.flash('success_msg')); then it will be empty.

And since I'm reading it

console.log('flash sucess before setting locals:', req.flash('success_msg'));  // Logs flash messages before setting locals
console.log('flash error before setting locals:', req.flash('error_msg'));  // Logs flash messages before setting locals
res.locals.success_msg = req.flash('error_msg')[0] || ''; 
res.locals.error_msg = req.flash('error_msg')[0]|| ''; 

it is already empty where I want to store it in the res.locals

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Patrik Horemans