Get Query Parameter Input from the Client

Can someone help me figure out what I need to do? This is what I thought would work but I am only passing the second test for this problem:

app.get('/name', (req, res) => {
  var { name } = req.query;
  
  if (name === '?first=Mick&last=Jagger') {
    res.json({ "name": "Mick Jagger" });
  } else {
    res.json({ "name": "Keith Richards"  });
  }
});

Nevermind, it was actually very similar to the previous problem. I overcomplicated it:

app.get('/name', (req, res) => {
  var first = req.query.first;
  var last = req.query.last;
  res.json({"name": `${first} ${last}`});
});
1 Like