[英]how to check if a parameter is present in the querystring in node.js
How to validate if a parameter is exits in the querystring or not in the node.js ? 如何验证参数是否在node.js中的querystring中退出?
I am validating like this 我这样验证
if(prm1 == null)
return error
But actually in the console.log(prm1) says undefined.. 但实际上在console.log(prm1)中说未定义..
How to validate this exactly ? 如何验证这一点?
If the parameter is not present in your queryString it is returned as undefined
. 如果queryString中不存在该参数,则返回为
undefined
。 The parameter wouldn't return null
because it wasn't initialised. 该参数不会返回
null
因为它未初始化。
try this : 尝试这个 :
if(typeof prm1 != 'undefined')
return "error";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.