Reputation: 801
What's the difference between writing routes:
//in this style
router.route('admin').get(getAllAdminsController).post(createAdminController)
and this type of writing:
router.get('admin', getallAdminsController);
router.post('admin', createAdminController);
Upvotes: 0
Views: 131
Reputation: 6853
There's no difference in terms of functionality. The first style is called chained route, and the purpose of it based on the documentation is:
Because the path is specified at a single location, creating modular routes is helpful, as is reducing redundancy and typos
From: https://expressjs.com/en/guide/routing.html#app-route
Upvotes: 1