Route

In the backend, we will add a GET route that queries the Game collection with an ID and returns the game in the response.

mern-vrgame/server/routes/game.routes.js:

router.route('/api/game/:gameId')    .get(gameCtrl.read)

The :gameId param in the route URL will be processed first to retrieve the individual game from the database. So we will also add the following to the game routes:

router.param('gameId', gameCtrl.gameByID)

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.