Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda