Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
Get express.js query param dynamically

So I have this code, which checks if a argument is whether given or not and has a value or not.

const isSetAndNotEmpty = (parameter) => {
    return (req, res, next) => {
        //Define param ( is there a way to make this working with the parameter from above )
        const param = req.query.id;

        //Check param
        if (!param || typeof (param) === 'undefined') {
            return res.json({
                success: false,
                message: `Argument '${parameter}' is missing or empty!`
            });
        }
        next();
    };
};

Is there a way to give the param variable the same value as the parameter? Because the way I see it works is that whatever I give the req.query.xxx it will take it as a query parameter.

Just saying req.query.parameter is not working because of the reason that it will be taken as a query parameter.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!