Controller 

The list controller method will query the Game collection in the database to return all the games in the response to the client.

mern-vrgame/server/controllers/game.controller.js:

const list = (req, res) => {  Game.find({}).populate('maker', '_id name') .sort('-created').exec((err, games) => {    if(err) {      return res.status(400).json({        error: errorHandler.getErrorMessage(err)      })    }    res.json(games)  })}

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.