May 2018
Intermediate to advanced
470 pages
13h 54m
English
On the frontend, we will add a corresponding fetch method in api-game.js to make a POST request to the create API by passing the form data collected from the signed-in user.
mern-vrgame/client/game/api-game.js:
const create = (params, credentials, game) => { return fetch('/api/games/by/'+ params.userId, { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + credentials.t }, body: JSON.stringify(game) }) .then((response) => { return response.json(); }).catch((err) => console.log(err)) }
Read now
Unlock full access