Saturday, August 11, 2012

Flash messages on Express js 3

Trying Express js 3 and received an exception on the following?
req.flash()
TypeError: Object # has no method 'flash'

Apparently Express js has dropped support for flash messages in their latest version - 3.
Here's the recommended middle-ware plugin to resolve the problem:

Gotchas:
Be sure to use
app.use(flashify);
before
app.use(app.router);
for it to work.

Enjoy!

No comments: