Fetch

In the frontend code, we will add a fetch method to utilize this read API to retrieve the details of an individual game according to its ID.

mern-vrgame/client/game/api-game.js:

const read = (params, credentials) => {  return fetch('/api/game/' + params.gameId, {    method: 'GET'  }).then((response) => {    return response.json()   }).catch((err) => console.log(err)) }

This read API will be used for the React views fetching a game detail and also the React 360 game view, which will render the game interface.

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.