Get Query Parameter Input from the Client not passing

my code still not passing, despite carefully following the instructions
code: app.get(’/name’, (req, res) => {
let firstname = req.query.first;
let lastname = req.query.last;
res.json({ “name”: firstname + " " + lastname })

1 Like

Are you not retrieving loading the page first?


that should be from prev. exercises

In order to send the data, they expect that page with a form.

Just one other suggestion, use destructuring for the req.query object.

i also followed the exact example from the lesson illustration
code: app.get(’/name’, (req, res) => {
const {"/name?first=firstname&last=lastname"} = req.query;
res.json({“name”: ‘firstname lastname’});
still not passing

its already in the code from the prev lessons, and what do you mean “expect the page with a form”…and thank you for taking ur time to respond

nvm. You may include the link to your repl so someone can take a better look at the code and help you out…

here it is

my code still not after several hours of browsing github and stackoverflow…is this a glitch from FCC? im deeply worried. pls any help
code: app.get(’/name’, (req, res) => {
let first = req.query.first;
let last = req.query.last;

name: ${first} ${last}

It is not, I’ve checked out your page and with a simple fix it passes, so you’re very close. Getting stuck is always beneficial.

There is an error here:

app.get('/name', (req, res) => {
  var { firstname: firstname, lastname: lastname } = req.query;
    name: `${firstname} ${lastname}`

You could do some console logs and get what is going on. But let me give some context & background in case it helps.

context & background

Let’s see again what the exercise asks for:

  • Respond to a GET request landing with params first and last, with a json object

A get request, if it sends any query parameters (as a way to send information to a server like in a google search). It sends them with this format:
where will instead be any url, in your case, it’s your public url (the webpage).

They are sending this url with query parameters:

  • yourUrl/?first=name&last=surname
    where name and surname could be coming from the form, with a GET method.

The exercise

Alright, then, your data should be like this, in the req.query object:


here is where the error comes in.

How do you destructure that object?

thanks a bunch ive solved it using
code: app.get("/name", (req, res) => {
let str = req.query.first + " " + req.query.last ;
res.json({name: str})

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.