https://supertokens.com/ logo
#support-questions
Title
# support-questions
i

ITEnthusiasm

06/11/2022, 9:12 PM
The SuperTokens backend APIs are supposed to let us know if the response didn't turn out okay, right? Will it let us know through the
response.status
? Or do we have to find out from the
response.json().status
? (Stated differently, is there a way to know that an error occurred without JSON-ing the response?)
r

rp

06/12/2022, 5:47 AM
hey! if the API throws a 500 error, it will be reflected in the HTTP status code of the response.
i

ITEnthusiasm

06/12/2022, 11:00 AM
Okay. Does that mean 400 errors will be left to the
json
body?
r

rp

06/12/2022, 11:01 AM
Nope. 400 as well will he http status code. You should check the json body only if the status code is 200
i

ITEnthusiasm

06/12/2022, 11:04 AM
That is indeed odd. 🤔 Maybe it's how I'm making the request? Whenever I get the response back from SuperTokens, the
status
for a
fetch
always seems to be
200
. I've been having to do
await response.json()
to check the
status
property on the JSON object (to know if there was an error or not)
r

rp

06/12/2022, 11:05 AM
Well. The json body also had a status property which indicates what happened in the API
If there are non 200 status code result, it means your input was invalid in the API, or that something like a db connection went wrong etc.
Vs if the http status is 200, but the status in the json body is not OK, then it means that the API ran fine, it’s just a user error than happened. L
i

ITEnthusiasm

06/12/2022, 11:07 AM
Ahhhhh okay. That makes more sense. Thanks