HTML response with 502 error from API end-point

I am not Twitch, I am not Twitch staff, just another community developer.

If I get a 5xx error what I do next depends on what data I was trying to get, if it’s streams I’ll retry, if it’s something for an extension, I’ll report an error to the user/viewer and ask them to reload the page.

Most of the 4xx errors will be authentication errors, generally speaking, and you get a JSON blob back with a “message” describing the problem. It’s not directly documented no

Add a retry counter to your code and fail/error out after 2/3 goes?

Whilst you could in theory, when the server is 5xx it just wants to die, so the less work the server does the better for the server.

What happens if the server errors whilst attempting to generate the JSON?

If you want to raise this as a feature request (return JSON when nginx is dying/reading a bad response from the backend). You can make this request on the uservoice

https://twitch.uservoice.com/forums/310213-developers