I am using node.js restify.
I have a HTTP GET request that looks like this;
http://127.0.0.1//read_val?XXX=123&YYY=456&ZZZ=789
In my handling function, to retrieve the URL parameters, the relevant code will be like this;
var api_get_func = function (app, url_path) {
function respond(req, res, next) {
var XXX= req.query.XXX;
var YYY = req.query.YYY;
var ZZZ = req.query.ZZZ;
//SQL query ...
return next();
}
app.get(url_path, respond);
}
Now, what if I have a HTTP GET function like this below
http://127.0.0.1//read_val?XXX=123&YYY=456
The ZZZ
parameter is not provided in the URL. How do I modify the code such that ZZZ
will use a default value of, say, 111
?
''
is not truthy; the rest of this follows though – Makeyevka