It works for one channel, but then when I try to get it to go though all the channels with loop like this, it won’t work:
for (id=0;id<channelsArray;id++) {
getStream(id);
};
I thought it had something to do with it being asynchronous, so if the request doesn’t get a response right away it just keeps going…I’m missing something, or not understanding something but I don’t know what it is. How I can I fix this code so that it will go through all the channels and tell me their stream status? Any help or hints would be appreciated. Thanks!
Try using .forEach on the array of channels instead of using a for-loop. With that approach, you’ll have to modify getStream(id) into getStream(name). Then replace channelsArray[id] in the url with name.
Or try initializing id in the for loop header with the let keyword.
EDIT @kunalgupta05 I didn’t see the missing .length . That might work.
I suppose, no pain, no gain! There is definitely some pain, but it’s a good pain, especially when I finally solve whatever the problem (or in this case get someone to solve it for me).