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

175
Views
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 answers
Answer question

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 Report
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!