You are developing a user management system and need to design routes for CRUD operations. How would you structure the routes to follow RESTful principles in Express.js?

  • Use any route structure that suits your needs
  • Design routes like /createUser, /getUser, /updateUser, /deleteUser
  • Structure routes as /users, using HTTP methods (GET, POST, PUT, DELETE) to indicate CRUD operations
  • Create routes like /addUser, /fetchUser, /modifyUser, /removeUser
To follow RESTful principles in Express.js, you should structure routes as a resource, such as /users, and use HTTP methods (GET, POST, PUT, DELETE) to indicate CRUD operations on that resource. This approach aligns with RESTful conventions, making your API more intuitive and standardized. Option 2 doesn't follow RESTful principles, and Options 1 and 4 lack the structured approach recommended for RESTful APIs.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *