Couldnt understand how to use post handler

Tell us what’s happening:
I did pass the challenge however I cant get myself to understand how to use the

app.route(path).get(handler).post(handler)

as they mentioned in the note section below. I simply used app.get(…) and I was able to pass the challenge. But it says the writing the code in the second way(as mentioned in the note section:
“This syntax allows you to chain different verb handlers on the same path route. You can save a bit of typing, and have cleaner code.”

Your project link(s)

solution: https://replit.com/@tomvsaji/boilerplate-express-1

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0

Challenge: Get Query Parameter Input from the Client

Link to the challenge:

The ExpressJS documentation has an example of chaining HTTP method handlers.


I would highly recommend you refer to the official documentation (NodeJS, Express, MongoDB, Mongoose, etc.) for the backend challenges and projects. Only relying on the information given in the challenges is likely not going to cut it.

2 Likes

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