I am not sure if its todo with how i am trying to save the data to the array but using console.log the array seems to be empty and thus cannot display data from it. Please see if my current code is properly structured:
I would like to confirm matchIds actually contains an array of data:
var getGameData = function (matchIds) {
console.log('Executing getGameData');
return new Promise(function (resolve, reject) {
var gameData = [];
for (var i = 0; i < matchIds.length; i++) {
lolapi.Match.get(matchIds[i], function (error, gamedata) {
if (error) {
return reject(error);
}
if (gamedata) {
gameData.push(gamedata);
}
});
if (i === 9) {
resolve(gameData);
}
}
});
};