express route with multiple params code example
Example 1: expressjs path multiple params
app.get('/fruit/:fruitName/:fruitColor', function(req, res) {
var data = {
"fruit": {
"apple": req.params.fruitName,
"color": req.params.fruitColor
}
};
send.json(data);
});
Example 2: add multiple params to express params
app.get('/hello/:firstname/:lastname', (req, res) => {
console.log(req.params);
res.send('hello ' + req.params.firstname + ' ' + req.params.lastname);
});