April 2020
Intermediate to advanced
716 pages
18h 55m
English
In the backend of the MERN VR Game application, we will expose an API that will retrieve the details of an individual game, specified by its ID in the game collection. To achieve this, we can add a GET API that queries the Game collection with an ID and returns the corresponding game document in the response. We will start implementing this API to fetch a single game by declaring a route that accepts a GET request at '/api/game/:gameId', as shown in the following code:
mern-vrgame/server/routes/game.routes.js:
router.route('/api/game/:gameId') .get(gameCtrl.read)
When a request is received at this route, the :gameId param in the route URL will be processed first to retrieve the individual game from the database. So, we will ...
Read now
Unlock full access