What am I doing wrong in my code here since I can’t get the ‘qkey’ value?
If I test ‘/search/firstname/daniel’ in my browser, my response is: {“qkey”:”daniel”}
app.get('/search/:qkey/:qvalue', function(req, res){
var qkey = req.params.qkey;
var qvalue = req.params.qvalue;
var query = {qkey:qvalue}
console.log(query);
res.send(query);
});
The problem is the way you create
queryobject. You can’t assign a dynamic value to a property name using curly bracket syntax. What you should do instead is;