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

sharma

07/19/2022, 1:30 PM
Regarding supertokens-web-js
supertokensEmailPassword.signUp
, is the returned promise rejected in case of FIELD_ERROR? Initially I wrote the code inside .catch to deal with FIELD_ERROR but on debugging found that the code does not reach
.catch
, but it is inside
.then
. Is it intended?
r

rp

07/19/2022, 1:32 PM
the promise is not rejected in that case.
the promise will be rejected only in cases of a >= 400 error status code
s

sharma

07/19/2022, 1:34 PM
What will be the result object schema in that case?
The references mentions this
Copy code
Promise<{ fetchResponse: Response; status: "OK"; user: UserType } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>
Which means resolved -
{ fetchResponse: Response; status: "OK"; user: UserType }
rejected -
{ error: string; id: string }[]; status: "FIELD_ERROR" }
but it seems the rejected schema is also appearing in resolved state. is rejected schema same?
r

rp

07/19/2022, 2:16 PM
it doesn
it doesn't get rejected
they both are resolved.
s

sharma

07/19/2022, 2:19 PM
> he promise will be rejected only in cases of a >= 400 error status code what about this?
r

rp

07/19/2022, 2:19 PM
im not sure how i can make this more clear. Please see the swagger API spec 🙂
s

sharma

07/19/2022, 2:21 PM
swagger doesn't have 400 response.
anyways, let me dig around
r

rp

07/19/2022, 2:22 PM
you can just show a somethign went wrong message on reject. On resolve, you check the status from the body and change the UI accordingly.
4 Views