var channelsData = [];
//let's assume i have here 3 objects from api calls here
How I can loop through this and get the objects.I tried with
for
loop and
forEach
but still got nothing and if i try to get channelsData.length , i get 0.
If i try to console.log channelsData i get this [in the console][1]
[1]: https://i.stack.imgur.com/TkMLS.png Code:
$(document).ready(function() {
var channels = ["andreiknight", "freecodecamp","creativemonkeyz"];
var channelsData = [];
var channelsData = [];
channels.forEach(function(channel) {
$.getJSON("https://wind-bow.glitch.me/twitch-api/channels/" + channel + "", function(data){
//console.log(data);
channelsData.push(data);
});
});
channelsData.forEach(function(channel){
console.log(channel); // returns nothing in the console
})
});