Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

207
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda