jaredhanson / connect-flash

Flash message middleware for Connect and Express.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

req.flash returns empty array

sakirma opened this issue · comments

Hi,

I have been using connect-flash for my nodejs server which uses express 4 and it is hosted from localhost:3000.
This works fine when I post with postman, but if I call this server from another server then req.flash() returns an empty array

Sorry, I think I figured out where the problem comes from.

I use Ionic + Angular and a httppost first calls an OPTION method before calling a POST method. Which could be the reason why flash is consumed before the POST method

Problem still persists

If you are console logging req.flash() before actually passing it back to the client, the console log will consume what is inside the req.flash() before you pass it on. This is because the flash middleware is only single read. So take out the console log!