Work on this project was going smoothly until I got stuck. I am sure there is a simple explanation to my problem, but I can’t manage to work it out on my own.
I am making two separate calls to pull the data about streaming channels and the offline channels.
First of all for some reason even though I get the right data about streaming channels and I manage to display them on the page I still get an error in the console “TypeArror: stream.data is null” about the channels which are currently not streaming. I can’t understand why it’s happening.
Secondly, I am trying to push offline channels into a separate array, but it doesn’t work. Array remains empty at all times.
I created three arrays.
channelsArr - contains names of the channels I want to display on the page. I make a call to check for the streaming channels and trying to separate the online and offline channels into two other arrays.
onlineArr - gets names of the streaming channels after the request.
offlineArr is where I want to put channels’ names which are currently not streaming and this is where I’m stuck. I’m comparing a name from the channelsArr to a name from onlineArr and if the name from the channelsArr is not in the onlineArr I’m pushing it into offlineArr. I tried everything I could think of, using different approaches, but offlineArr remains empty.
Here is the link to the project: https://codepen.io/themalni/pen/jVLmQR