How do I check if a query string passed to an Express.js application contains any values? If I have an API URL that could be either: http://example.com/api/objects
or http://example.com/api/objects?name=itemName
, what conditional statements work to determine which I am dealing with?
My current code is below, and it always evaluates to the 'should have no string' option.
if (req.query !== {}) {
console.log('should have no query string');
}
else {
console.log('should have query string');
}