I have a url with a boolean query param: www.myUrl.com?foo=true
on my server, I have the following:
if (req.query.foo) {
//do something
}
but then realized that was just checking for the presence of the param and not the value so that if I did www.myUrl.com?foo=asdasd
, it'd still pass the conditional .
I then changed it to this (checking against a string) :
if (req.query.foo === 'true') {
//do something
}
and that seems to work as intended. However, should I be using a boolean instead though, like req.param.foo === true
(comparing against a boolean rather a 'true' string)?