I'm currently facing an issue with this function I have.
function customCheck(username){
var result = "normal";
$.getJSON('https://api.twitch.tv/kraken/streams/' + username, function(data){
if(data.stream == null)
result = 'offline';
else
result = 'online';
}).fail(function(){
result = 'notfound';
});
return result;
}
console.log(customCheck('streamer123'));
The problem lies in the fact that when I check the console log, it always displays "default" instead of "offline", "online", or "notfound" as expected.
I've attempted to rearrange the code by moving the console.log() line before the customCheck() function, but unfortunately, it didn't solve the issue. Also, trying to define the variable result globally did not resolve the problem either.
If anyone has any suggestions or solutions, please feel free to share them!