April 2020
Intermediate to advanced
716 pages
18h 55m
English
To display the details of an existing auction in a view of its own, we need to add a backend API that will receive a request for the auction from the client and return its details in the response. Therefore, we will implement a read auction API in the backend that will accept a GET request with a specified auction ID and return the corresponding auction document from the Auction collection in the database. We will start adding this API endpoint by declaring a GET route, as shown in the following code.
mern-marketplace/server/routes/auction.routes.js:
router.route('/api/auction/:auctionId') .get(auctionCtrl.read)
The :auctionId param in the route URL invokes the auctionByID controller method when a GET request is ...
Read now
Unlock full access