In this post, we will see how to resolve The api route users/userId/{userId} needs to be changed to users/?id=abc
Question:
API route needs to be changed as I want to take the id as a parameter.Best Answer:
Express cannot route based on query string so you’ll need custom middleware to decide which handlers to call based on the request./users
->authenticate, userValidator.getUsers, users.getUsers
/users?id=abc
->users.getUserById
For example
If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com