4

I'm trying to get some flashmessages from an express app.

My understanding is that flash messages in express (eg: req.flash('info',message)) are stored on the server, and only upon next request is it loaded into the view?

So if I have a one page ajax website, should I not use the built in flash method and instead just use send, or should I do something else, like making another request to a view?

Thanks.

Mark
  • 32,293
  • 33
  • 107
  • 137

1 Answers1

2

Your understanding is my understanding about Express flash messages.

I use something like:

In the route:

req.flash('error', 'message to be flashed');

And then something like below that can be rendered in a view.

- if(error.length){
  ul
  - error.forEach(function(err){
    li= err
  - })
- }

I've yet to make a one page site with Node+Ajax but hopefully this helped some.

JohnAllen
  • 7,317
  • 9
  • 41
  • 65