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
Turns out when catching error from Api class, now the error is in other place
constpayload=e?.error;// it will hold the parsed JSON which usually is in axios response's bodyconststatus=e?.status;consttraceId=e?.headers?.get?.("traceid");
Hi, I have a question regarding error handling in the API response. When we encounter an error, we receive an Error object, but I can't access the body of the response. If bodyUsed is set to true, it suggests that the body has been processed (during "normal" axios/fetch call it's not touched), yet I can't find any error details and where it was processes.
I understand that in a plain axios/fetch we aren't calling response.json() before inspecting the Response, so bodyUsed stays false. Here, the generated client calls it for us (because I set format: 'json' during init), so the body is consumed earlier. Is there a way to access the error details (because when I do manually send "wrong" params/body to endpoint I get properly an error in web swagger)? Any insights would be greatly appreciated.
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
[SOLVED]
Turns out when catching error from Api class, now the error is in other place
Hi, I have a question regarding error handling in the API response. When we encounter an error, we receive an Error object, but I can't access the body of the response. If
bodyUsed
is set totrue
, it suggests that the body has been processed (during "normal" axios/fetch call it's not touched), yet I can't find any error details and where it was processes.Here's the code I'm using:
The response I get is:
I understand that in a plain axios/fetch we aren't calling response.json() before inspecting the Response, so bodyUsed stays false. Here, the generated client calls it for us (because I set format: 'json' during init), so the body is consumed earlier. Is there a way to access the error details (because when I do manually send "wrong" params/body to endpoint I get properly an error in web swagger)? Any insights would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions