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`);
                else {

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



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 === "") 

Answered By – Abbas Shaikh

Answer Checked By – Timothy Miller (AngularFixing Admin)

Leave a Reply

Your email address will not be published.