April 2020
Intermediate to advanced
716 pages
18h 55m
English
Sellers in the marketplace will see a list of auctions that they created. To retrieve these auctions from the database, we will define a backend API that accepts a GET request and queries the Auction collection so that it returns the auctions by a specific seller. To implement this auctions by seller API, we will declare a route, as shown here.
mern-marketplace/server/routes/auction.routes.js:
router.route('/api/auctions/by/:userId') .get(authCtrl.requireSignin, authCtrl.hasAuthorization, auctionCtrl.listBySeller)
A GET request, when received at the /api/auctions/by/:userId route, will invoke the listBySeller controller method, which will query the Auction collection in the database so that it returns all the auctions ...