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
CodePudding user response:
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 === "")