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

180
Visualizações
Why req.query.code return a empty string?

i'm trying to get the code from the url body with "req.query.code", but is empty and the url show perfectly the code, i don't know what happen, this is my server.js file:

app.get('/validate', async (req, res, next) => {
                if (!req.query.code || req.query.code != "") {
                    console.log(clc.red(`Error: No code provided`));
                    res.send(`Error: The code is missing, please check the documentation`);
                    return;
                }
                else {
                    console.log(req.query.code);
                }
}

And when i saw the error, the url have the code.

http://xxxxxxxx:3001/validate?code=xxxxxxxxxxa64779xxxxxe42fe16xx8063xxxx2xxxx
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have problem in your if condition in or operator in second condition you're checking for non-empty req.query.code because of which the if block is getting executed try this

            if (!req.query.code || req.query.code === "") 
               
                
about 4 years ago · Juan Pablo Isaza Relatório
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