in backend/Functions/HTTP/mygames_list/app.js [28:61]
async function getMyGames(pk) {
// provide list of games for user back to UI
// OwnerGames Index on
// gameinfo.playerName
const parms = {};
parms.TableName = playerInventoryTableName;
parms.KeyConditionExpression = '#key = :v1';
parms.ExpressionAttributeValues = { ':v1': pk };
parms.ExpressionAttributeNames = { '#key': 'pk' };
parms.ProjectionExpression = 'sk, gameId, quizName, quizDescription, '
+ 'questionType, quizMode, inventoryType, category';
let results;
try {
results = await ddb.query(parms).promise();
} catch (e) {
console.error(`could not retrieve games ${JSON.stringify(e.stack)}`);
return { statusCode: 500, body: 'Could not retrieve games' };
}
let result;
if (Object.prototype.hasOwnProperty.call(results, 'Items')) {
result = results.Items;
return {
statusCode: 200,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(result),
};
}
result = 'NoResults';
return {
statusCode: 200,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(result),
};
}