我正在嘗試使用“req.query.code”從 url 正文中獲取代碼,但是它是空的,并且 url 完美地顯示了代碼,我不知道會發生什么,這是我的 server.js 檔案:
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);
}
}
當我看到錯誤時,網址有代碼。
http://xxxxxxxx:3001/validate?code=xxxxxxxxxxa64779xxxxxe42fe16xx8063xxxx2xxxx
uj5u.com熱心網友回復:
您的 if 條件或第二個條件中的運算子有問題您正在檢查非空 req.query.code 因為 if 塊正在執行嘗試這個
if (!req.query.code || req.query.code === "")
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/483945.html
標籤:javascript 节点.js api 网址
