Hey!
So I am trying to get a code on my website to update multiple streamers Live viewers. I was successful in being able to call Total Views and Follows, as well as whether or not the channel is live. Of course, however, this was all done through GET: /channels/:user and not GET: /streams/:channel
Here is the JavaScipt (JQuery) I am using
jQuery(document).ready(function ($) {
$('.viewers').each(function () {
var tnick = $(this).data('tnick');
var span = $(this).next();
$.getJSON('https://api.twitch.tv/kraken/streams/' + tnick + '.json?callback=?', function (data) {
var views = data.viewers;
span.html(views);
});
});
});
and here is the HTML I am using to send the requests
<p><i data-tnick="lirik" class="user-color fa fa-user viewers"></i>
<span>Offline</span></p>
I can see that the request is sending, but it just can’t get the Array back with the Live Viewers, so it is staying as offline. Here is the JSFiddle of that code above.
Just to show that, this code works with getting things from GET: /channels/:username here is a JSFiddle with a working live follower check.
I am not a JavaScript developer, so testing to see if the code is working through Google Inspect, and seeing what’s wrong isn’t my strong suit. I posted on StackOverflow, wasn’t able to get any help.
Any Ideas?