searchGameSessions call from Script - return value confusion

While writing a JS Lambda Function whose purpose is to search through Game Sessions accepting players on a single fleet, create a player session in one of the game sessions and return that player session to the application client, I have encountered a problem dealing with the return value of gamelift.searchGameSessions

I was able to diagnose the problem stemming from my handling of a returned gameSessions object. According to Amazon documentation [], gameSessions should return a list with each index being an active game session on the fleet that matches the filter expression (in my case, hasAvailablePlayerSessions=true).

The error log shows I am capturing the one created gameSesssion that matches the filter expression, but after assigning the returned value from the searchGameSessions function to a variable called gameSessions, I assigned selectedGameSession = gameSessions[0] which should return the gameSession object held in the 0th index of gameSessions. However, this assigment results in selectedGameSession.GameSessionId = undefined, which prevents me from creating a player session in the game session. Not sure how else to approach this particualr problem

It might be easier to show your code snippet. Also theres is a specific Javascript reference for all the AWS SDK stuff, ie

I don’t have a JS environment setup but I wonder if you are accessing the gameSessions session results correctly.

gamelift.searchGameSessions(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else  {
     gameSessions = data.GameSessions
     firstSession = gameSessions[0]

You can see a lot of Javascript code similar to this at