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

179
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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