Twitch API: It returns undefined and I can't find the solution (SOLVED)

Hello. I am stuck in the “Twitch API” project because when I want to show my channels name, it returns undefined for an unknown reason. Below I will write my code and I will put a link to my codepen.

$(document).ready(function() {
  var streamers = [
  var api = "";

  for (i = 0; i < streamers.length; i++) {
    var cApi =
      "" +
      streamers[i] +
    var sApi =
      "" +
      streamers[i] +
      type: "GET",
      url: cApi,
      datatype: "jsonp",
      jsonp: "callback",
      success: function(result) {
        var name = result.display_name;
        var logo = result.logo;

make the request to the api without the string “?callback=?” .

1 Like

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


Hello, I am trying to display who is online and who is offline but I can’t think of a solution.
This is my codePen url:

I will delete this topic once my problem gets fixed. Thanks.

Have to tested to see what you get when you call" + streamers[i]

on a steam that is offline?

Yes. I get null when someone is offline. The problem is that I don’t know how to show in my

  • who is online and who offline.
  • I’ve combined these topics since you’re still asking about the Twitch API.

    1 Like

    well if they are offline you get null so

    if(stream === null){
      // streamer is offline
     // do stuff here
      // streamer is online 

    Hint #2
    if a stream is offline call 1" + streamers[i]
    and see what you get