Cant access Array of Objects (help!) [solved]

Cant access Array of Objects (help!) [solved]
0.0 0

#1

I’m doing the Twitch API project, Codepen
I want to get the details of channels from API, and store useful data in objects, and then push that objects to an array, because I’m planning to use that array later in the project.

here how I declared an array, (project code line 4)

var channelObjs = [];

This is how I created an object and pushed it to the array, (line 13)

var channelDetails = {                     
            "live" : false,
            "name" : offlineChannel.display_name,
            "secondName" : offlineChannel.name,
            "logo" : offlineChannel.logo,
            "link" : offlineChannel.url
             };          
channelObjs.push(channelDetails);  

the problem is I cant access this array,
when I run console.log(channelObjs) in project code it shows the array, but console.log(channelObjs[0]) returns ‘undefined’. please help me


#2

There are no issues with push() LOL :see_no_evil:. this happens because console.log(channelObjs) runs before getJSON() method finished.