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 9173699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:37:44+00:00 2026-06-17T16:37:44+00:00

The code below demonstrates trying to log req.hash_id from middleware. It’s showing up for

  • 0

The code below demonstrates trying to log req.hash_id from middleware. It’s showing up for me as undefined. Is there anyway that I can get this to work? Or easily parse “:hash” out in regular .use middleware?

app.param("hash",function(req, res, next, id){
  req.hash_id = id;
  return next();
});

app.use(function(req, res, next){
  console.log(req.hash_id);
  return next();
});
  • 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-17T16:37:45+00:00Added an answer on June 17, 2026 at 4:37 pm

    I don’t think you can use req.params inside a middleware function as it is bound to specific routes. You could use req.query though, but then you have to write your routes differently, e.g. /user?hash=12345abc. Not sure about passing the value from app.param to app.use.

    If you have a specific structure for your routes, like /user/:hash you could simply write

    // that part is fine
    app.param('hash',function(req, res, next, id){
      req.hash_id = id;
      return next();
    });
    
    app.all('/user/:hash', function(req, res, next) { // app.all instead app.use
      console.log(req.hash_id);
      next();  // continue to sending an answer or some html
    });
    
    // GET /user/steve -> steve
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is a small test case that demonstrates a problem that I am trying
EDIT: Changed example below to one that actually demonstrates the SIOF. I am trying
The code below demonstrates a behavior of gcc 4.6.2 that I can't account for.
Code below is used to save PostgreSql database backup from browser in Apache Mono
The code below simply didn't work. document.getElementById('files').addEventListener('change', handleFileSelect, false); reported by firebug that this
The code below demonstrates this difference: #include <iostream> #include <string> int main() { char
I am using Java 1.7 and as the code below demonstrates (compiled with Oracle's
I'm trying to recompile older code in latest Visual Studio (2008) and code that
The code below demonstrates this #include <float.h> #include <stdint.h> #pragma fenv_access(on) // apparently ineffective
I've run into a rather interesting problem. The code below generates an array that,

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.