I've got a problem with getting data from a callback inside a for loop
getClipsFromFollowers: function (gameList, streamerList, callback) {
var allClips = []
console.log("gamelist in getclips", gameList);
for (game of gameList) {
console.log("game in getclips", game);
clipsGameManager.getListByName(game, function (error, list) {
if (list == []) {
twitchManager.getTopClipsFromGame(game, function (clips) {
clipsGameManager.createGameClips(game, clips, function (error, status) {
if (error != null) {
console.log(error)
} else {
if(list != null){
console.log("listfromGame getclips", list)
allClips = allClips.concat(list)
}
}
})
allClips = allClips.concat(clips)
console.log(clips);
})
}
})
}
console.log("allclips in getclips", allClips);
callback(null, allClips)
}
The logs looks like this:
gamelist in getclips [ 'Overwatch' ]
game in getclips Overwatch
allclips in getclips []
[]
So my question is what can I do to make this work? I've tried to use await() with no success. Thanks in advance!