Hi, whenever I try to append the status of freecodecamp, it keeps showing “undefined”. The console log print test as “false”. So I know it’s working, however on the screen, it’s showing as “undefined”. Am I doing something wrong?
It’s showing up like this
function getFreeCodeCamp() {
var name = "";
var pic = "";
var link = "https://api.twitch.tv/kraken/users/freecodecamp?client_id=epbr8ttvcdj3ox68n97j6q4u20jqyd";
$.getJSON(link, function (result) {
var status = getFreeCodeCampStatus();
name = result.display_name;
pic = result.logo;
console.log(name + "\n" + pic);
$("#userInfo").append(
"<div class='row userInfoBackground'>"+
"<span class='col-xs-4 userName'>"+
name+
"</span>"+
"<span class='col-xs-4 title'>"+
status+
"</span>"+
"<span class='col-xs-4'>"+
"<img class='image' src='" + pic + "'>"+
"</span>"+
"</div>"
);
});
}
function getFreeCodeCampStatus() {
var test;
$.getJSON(urlStream, function (result) {
var status = result.stream;
if (status === null) {
test = "false";
console.log(test);
return test;
}
else{
return result.stream;
}
});
}