How to parse the error in the json response

Hi everyone, sorry if this isnt the place for this question in advance!

When checking who follows who I stumbled upon a problem ( checking via https://api.twitch.tv/kraken/users/someoe/follows/channels/someoneelse ) :
If Person A is following Person B the json response will show you some kind of data, BUT
If Person A does not follow Person B in my console I see the following error :
GET https://api.twitch.tv/kraken/users/anotherttvviewer/follows/channels/hidemon?client_id=… 404
In the error response {“error”:“Not Found”,“status”:404,“message”:“Person A is not following Person B”}
Thats alright and all, but how can I parse that even if its a 404 error ?

For example I want to parse the “message” in #myDiv

json parse the body response. Or just assume that a 404 means person a is not following person b.

Can’t advise much else without seeing your code.

This is more a general issue with your code and not the API. So the language you are using would/can/should be able to handle a 404

Hi Barry
I am checking multiple people at once so something like
is person A following person Z
is person B following person Z
etc…
The code only gives me response when The first person is following the second, but not when he is not

The code here

         $.ajax({
         dataType: "jsonp",
         jsonp:"callback",
         url: "https://tmi.twitch.tv/group/user/hidemon/chatters",
          success: function viewera(data){

//seeing the result in the console
console.log(data);
//gets the viewers
  $.each(data.data.chatters.viewers, function(i, field) {
      var viewers = field;
      // Check if they are followers!
      
      
            var follow = "https://api.twitch.tv/kraken/users/" + viewers + "/follows/channels/" + userName + "?client_id=xxx";
             $.getJSON(follow, function(resulta){
                 $.each(resulta, function(i2, field2) {
           
                $("#go").append("<p>" + field2 + "</p>");
            
             });        
             });

I did not find anything related to my problem on stackoverflow so I was hoping I can find some help here !
Thank you in advance!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.