Express middleware for storing messages in the session. Connect-flash was part of Express until Express 3. connect-flash
Questions tagged [connect-flash]
107 questions
0
votes
3 answers
'messages is not a function' nodeJs
messages is not a function
Why != messages('message',locals) is showing me error
even though it is right
Please help me to find error. thank you
app.js
app.use(require('connect-flash')());
app.use(function (req, res, next) {
res.locals.messages…

Shankar Ghimire
- 138
- 4
- 15
0
votes
1 answer
flash messages are not saved before the page is rendered (node)
As part of a generic get route in an express application, I want to send two flash messages with express-session and connect-flash. This all works except that req.flash does not save before the page is rendered. As a result, the flash messages do…

Adam B
- 163
- 1
- 13
0
votes
4 answers
How do I use req.flash() with nunjucks?
I am using connect-flash to pass the flash message. In my controller, I am using the following code if (!req.user) {
req.flash("error_msg", "User not found !!");
return res.redirect(307, '/');
}
In my view, I tried
{{…

Tech Team
- 109
- 13
0
votes
1 answer
Nodejs connect-flash | Passportjs pass different message type instead of 'error'
I want to pass different message type because im using bootstrap 4x it doesn't have alert alert-error. How would you change it?
passport.js

Thatguym
- 1
0
votes
0 answers
req.flash() requires sessions but sessions exist
Stack: Mongo/Redis, Express and Node
I have my sessions set as most other Stack Overflow posts point to. I am using Redis as my session store. This is my session setup:
app.use(session({
resave: true,
saveUninitialized: false,
cookie: {
…

joshk132
- 1,011
- 12
- 37
0
votes
0 answers
Why is flash a property of request and not response?
I'm new to Express and I'm currently learning how to flash messages. When we use a module such as connect-flash, we are supposed to do it in the format req.flash(type,message). We cannot call .flash() on a response res. Why is it that we do the…

rb612
- 5,280
- 3
- 30
- 68
0
votes
2 answers
Convert to JS Object
How to convert this to JS object:
{"info":["Image has been added"],"success":["No success Sorry!"]}
JSON.parse throws an error and says " isn't valid JSON. Am new to JS and can't figure out how to deal…

Aditya Raj
- 327
- 3
- 14
0
votes
1 answer
How to pass a link to req.flash() in express.js
I have been trying to figure out a way of passing a link in req.flash() in my js file, without actually doing that in html template, because am using the alert message as a partial in other html pages, I wish to pass in resend verification link, is…

Fillipo Sniper
- 419
- 2
- 11
- 28
0
votes
1 answer
Node JS(Express) connect-flash not working on redirects action
I'm wondering why my connect-flash is not working.
I know connect-flash try to save message into session.
So I declare session like this :
app.use(session());
Then I set up flash :
app.use(flash());
The problem is that when I using with…

Richard
- 351
- 4
- 17
0
votes
1 answer
NodeJS Express App - Showing flash messages via Handlebars
I'm hoping someone can help with showing flash messages in Express via a Handlebars view (which uses the bootstrap markup).
In app.js I have the below modules and middleware to try and get flashes working
//require modules
const express =…

Stuart Brown
- 977
- 2
- 22
- 47
0
votes
1 answer
req.flash() returning an empty object in app.js but works fine in a controller method
So i am setting my flash messages inside my controller method like this:req.flash('info', 'flash is working') and then i console.log(req.flash()) in the controller to see if it works. Then in my app.js file i simply pass it on to a res.locals so…

Rhino
- 55
- 7
0
votes
0 answers
NodeJS, docker, nginx - req.flash() requires sessions
I have a problem with my Node application behind nginx.
On the begining, I will explain infrastructure:
NGINX => (prox_pass) => Docker (expose port to host) => Node APP
Application runs good, but I have problem with connect-flash (I use it with…

IceManSpy
- 1,078
- 1
- 13
- 35
0
votes
1 answer
EJS and connect-flash doesn't work as expected
I'm trying to wrap my brain around templates and flash messages using EJS and connect-flash along with express and express-session, but I can't seem to get it to work the way I want or expected.
When I define a flash message I console.log it, and I…

Brian Emilius
- 717
- 1
- 8
- 31
0
votes
1 answer
passportjs local connectflash not working with ejs
I have a project using passportjs fully working, but not showing flash messages.
The passportjs file looks like this:
passport.use('local-login', new LocalStrategy({
// by default, local strategy uses username and password, we will override…

Simon Guldstrand
- 488
- 1
- 5
- 24
0
votes
1 answer
How to put flash message into my code?
I have a function
function fileFilter(req, file, cb) {
if (file.mimetype !== 'image/png' && file.mimetype !== 'image/jpg' && file.mimetype !== 'image/gif' ) {
console.log('Wrong format!');
return cb(null, false);
…

Bim Bam
- 429
- 1
- 6
- 17