When responding to the connectToGame event, the socketIO packet parses the gameId and playerId values as single member arrays.
When gameId is passed to getGame as an array, I was seeing a crash in gameViewModel because the return value was undefined and was being passed to JSON.stringify.
The changes below send gameId as a single value as getGame expects in this scenario. I also just added an error check so that if the _.find still does return undefined for some reason, it will result in an empty object instead of undefined to avoid a crash of the node server.
When responding to the connectToGame event, the socketIO packet parses the gameId and playerId values as single member arrays.
When gameId is passed to getGame as an array, I was seeing a crash in gameViewModel because the return value was undefined and was being passed to JSON.stringify.
The changes below send gameId as a single value as getGame expects in this scenario. I also just added an error check so that if the _.find still does return undefined for some reason, it will result in an empty object instead of undefined to avoid a crash of the node server.