You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I get a success Response from the server it works good (first shows loading then success message). The problem is when I get a response with an error code, I get a runtime error for the whole app instead of the error toast.
When I tried to avoid this by giving a 200 code for the error response the app didn't crash, but the error message was in a success toast...
The responses also have a "success" field which I can use to handle this manually (choosing between success and error toasts) but then I will need to handle the loading as well.
Is this a problem with how axios is handling error codes or am I doing something wrong?
Thanks alot!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to wrap an axios.post call with toast.promise. My basic setup is:
When I get a success Response from the server it works good (first shows loading then success message). The problem is when I get a response with an error code, I get a runtime error for the whole app instead of the error toast.
When I tried to avoid this by giving a 200 code for the error response the app didn't crash, but the error message was in a success toast...
The responses also have a "success" field which I can use to handle this manually (choosing between success and error toasts) but then I will need to handle the loading as well.
Is this a problem with how axios is handling error codes or am I doing something wrong?
Thanks alot!
Beta Was this translation helpful? Give feedback.
All reactions