In the React 360 project folder, we will add an api-game.js file that will contain a read fetch method that makes a call to the read game API on the server using the provided game ID.
/MERNVR/api-game.js:
const read = (params) => { return fetch('/api/game/' + params.gameId, { method: 'GET' }).then((response) => { return response.json() }).catch((err) => console.log(err)) }export { read}
This fetch method is used in componentDidMount of the React 360 entry component to retrieve the game details.