April 2020
Intermediate to advanced
716 pages
18h 55m
English
In this section, we will implement an API to get orders for a specific shop so that authenticated sellers can view the orders for each of their shops in one place. The request for this API will be received at /api/orders/shop/:shopId, with the route defined in order.routes.js, as follows.
mern-marketplace/server/routes/order.routes.js:
router.route('/api/orders/shop/:shopId') .get(authCtrl.requireSignin, shopCtrl.isOwner, orderCtrl.listByShop)router.param('shopId', shopCtrl.shopByID)
To retrieve the shop associated with the :shopId parameter in the route, we will use the shopByID shop controller method, which gets the shop from the Shop collection and attaches it to the request object so that it can be accessed by the ...
Read now
Unlock full access