Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7947671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:30:03+00:00 2026-06-04T01:30:03+00:00

From req.flash() I got object { error: [‘Invalid username’] } . I pass it

  • 0

From req.flash() I got object { error: ['Invalid username'] }. I pass it to templates written in Jade using dynamic helpers. But when I do

for type in flashMessages
    p #{type}

in the template I got the message (‘Invalid username’) instead of the type in variable type.

Can you give me an advice how to get the type please? I would like to print flash messages like this:

for type in flashMessages
    each message in flashMessages[type]
        p.alert-#{type} #{message}

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:30:04+00:00Added an answer on June 4, 2026 at 1:30 am

    req.flash() is intended to either give you a flat list of all your messages, or a flat list of all messages of a particular type. Either way, the message objects themselves don’t tell you the type, cause it’s assumed you already knew that. Given that req.flash() is backed by req.session.flash, however, you can roll your own functionality.

    First, you’ll need to prepare your own list of messages that have the information you want, so that you can pass it to your view. E.g.,

    var messagesByType = req.session.flash || {},
        allMessages = [];
    Object.keys(messagesByType).forEach(function(type) {
        var messages = messagesByType[type] || [];
        messages.forEach(function(msg) {
            allMessages.push({ type: type, text: msg });
        });
    });
    req.session.flash = {};
    

    Second, make sure you make allMessages available within your template. E.g.,

    res.render('some-view', { messages: allMessages });
    

    This should give you something you can iterate over within your view like this:

    for message in messages
        p(class='alert-#{message.type}') #{message.text}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I go from: http://url:port/user?u=username to http://url:port/user/username when using Express framework on Node
From few months ago when i was using twitter, i was able to send
I have the following LINQ query - var data = (from req in db.tblRequirements
I got a table variable @RQ , I want it updated using a table-valued
Here's a slide from WWDC 2010 session 208: conn = [[NSURLConnection alloc] initWithRequest:req delegate:self
I need to send a HTTP request (and get XML response) from Flash that
Does any know how to load a XML into a Flash file using FlashVar?
call = https://aaa@api.twilio.com/2010-04-01/Accounts/sasa/Calls.xml fields = { To : +12321434, From : req.body.from } request.post
def post_to_twitter message = from some where url = URI.parse('http://twitter.com/statuses/update.xml') req = Net::HTTP::Post.new(url.path) req.basic_auth
Given code like this from a node.js neophyte like me: require('http').createServer(function( req, resp )

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.