Basic Node and Express - Get Route Parameter Input from the Client - Solution Not Working

I literally copied and pasted the code below from freeCodeCamp’s own guide on for the lesson titled " Basic Node and Express - Get Route Parameter Input from the Client" and it still doesn’t work.

app.get("/:word/echo", (req, res) => { const { word } = req.params; res.json({ echo: word }); });

I continue to get this response every time I submit my answer:

Test 1 : Your echo server should repeat words correctly Test 2 : Your echo server should repeat words correctly

What’s going on?

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:72.0) Gecko/20100101 Firefox/72.0.

Link to the challenge:
https://www.freecodecamp.org/learn/apis-and-microservices/basic-node-and-express/get-route-parameter-input-from-the-client

try using const word = req.params.word without object destructring

2 Likes

That worked! Thank you, kindly.

By the way, if you don’t mind me asking, would you be able to explain why my above solution wasn’t working? I’m just curious.

1 Like

to be honest, I don’t know exactly why object destructuring didn’t work, because in express docs req.params is an object http://expressjs.com/en/api.html#req.params
but I think the fcc test expect you to use the dot notation or the test environment doesn’t support object destructuring

1 Like