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 = [
"ESL_SC2",
"OgamingSC2",
"cretetion",
"freecodecamp",
"storbeck",
"habathcx",
"RobotCaleb",
"noobs2ninjas"
];
var api = "https://wind-bow.glitch.me/twitch-api/";
for (i = 0; i < streamers.length; i++) {
var cApi =
"https://wind-bow.glitch.me/twitch-api/channels/" +
streamers[i] +
"?callback=?";
var sApi =
"https://wind-bow.glitch.me/twitch-api/streams/" +
streamers[i] +
"?callback=?";
$.ajax({
type: "GET",
url: cApi,
datatype: "jsonp",
jsonp: "callback",
success: function(result) {
var name = result.display_name;
var logo = result.logo;
console.log(name);
}
});
}
});
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.