Get Route Parameter Input from the Client

I don’t understand how to set the route parameter and take the information and send it via JSOn.

Your code so far

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

** Instructions **

Build an echo server, mounted at the route GET /:word/echo . Respond with a JSON object, taking the structure {echo: word} . You can find the word to be repeated at req.params.word . You can test your route from your browser’s address bar, visiting some matching routes, e.g. your-app-rootpath/freecodecamp/echo .
Challenge: Get Route Parameter Input from the Client

Link to the challenge:

Hey @alejogb1,

The problem here is that the challenge wants you to create a GET route, but you made a POST route, so this wouldn’t pass the test. Make sure you know all the HTTP Request Methods… Here’s a link to an mdn article talking about it:

https://developer.mozilla.org/en-us/docs/Web/HTTP/Methods

1 Like