Empty Object Response from API call (via AJAX)

Hi all :slight_smile:

I’m using AJAX call to hit Kraken API. This was working yesterday night.

$.ajax({
type: ‘GET’,
url: ‘https://api.twitch.tv/kraken/search/streams?q=starcraft’,
headers: {‘Client-ID’: ‘xxx’},
success: function(data) {
console.log(data);
}});

It successfully populated _total, stream array, etc.

However, the API went down today, and after it came back up, this call is now returning just:

Object {_total: 0, _links: Object, streams: Array[0]}

What is going on? :person_frowning:

Probably a caching issue that stemmed from when Twitch had a brain aneurysm a short while ago. Should hopefully be back up soon

For example, “https://api.twitch.tv/kraken/search/channels?q=starcraft” is working right now, so probably just a bit until all end points are back up.

If it’s still not returning anything within an hour or two then probably something is up.

Thank you :slight_smile:

One thing I wanted to bring up: I tried changing “{‘Client-ID’: ‘xxx’}” to {‘Client-ID’: ‘’} and it still returned the empty JSON object. Shouldn’t it give me a bad request if the client ID is empty/wrong?

I’m not familiar with AJAX so i’m not sure how it handles a bad request, but when I view it on my end without a valid Client ID then I see the expected error messaging.

{“error”:“Bad Request”,“status”:400,“message”:“No client id specified”}

You may need to include proper error handling to see this messaging - a quick google provided the below example:

function handleAjaxError(jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 500) {
// Server side error
} else if (jqXHR.status == 404) {
// Not found
} else if (jqXHR.status == 400) {
//Bad request
}
}

$.ajax({
CODE HERE
success: function() { … },
error: handleAjaxError
});

I’m able to see the error message in console. If I omit the “headers” line completely from my request, I see {“error”:“Bad Request”,“status”:400,“message”:“No client id specified”}.

But if I keep the headers line but remove my client id, or if I replace my id with just a bogus id, it still returns an empty object as a response (and no errors). Do you think this is due to the caching you mentioned above?

Hmm I would still expect it to give the 400 error in a scenario where a invalid Client ID is provided or none at all, so I think it’s weird that you are seeing a different outcome (as in, no errors populated.) Though, I could be misinterpreting (or misunderstanding) something with AJAX due to my limited knowledge on it :slight_smile:

It may be a remnant of the server issues - as I still see zero results returned for this one (even with other games).

Still having this issue…Do you still see zero results for this one? Thank you so much for working with me.

Just checked it now and I got 76 objects returned so it looks like it’s back up and running!

Yep same! Thank you :slight_smile:

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