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
I created a Middleware which automatically throws on all HTTP errors.
This ensures that only 2xx requests are received directly by my client.
This currently requires me to always check if the error object in the response exists -> only then the type is narrowed down from SomeResponseType | undefined to just SomeResponseType.
I tried building a wrapper which removes the undefined from the return type of the GET/PUT/POST/DELETE functions, but was unsuccessful after many attempts :/
Do you have advice or is there a better way to archive this? :)
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.
-
Hello there 👋
I created a Middleware which automatically throws on all HTTP errors.
This ensures that only 2xx requests are received directly by my client.
This currently requires me to always check if the error object in the response exists -> only then the type is narrowed down from
SomeResponseType | undefined
to justSomeResponseType
.I tried building a wrapper which removes the undefined from the return type of the GET/PUT/POST/DELETE functions, but was unsuccessful after many attempts :/
Do you have advice or is there a better way to archive this? :)
Beta Was this translation helpful? Give feedback.
All reactions