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
It would be great if the options of the hc() would allow to add a custom response parser to centralize common code that we want to be executed on every response, e.g.:
our current solution is to wrap every client call with a custom method that checks for errors and converts to json, e.g. parseResponse(await client.myEndpoint.$get())
Would it be feasible to implement this as it will likely complicate typing the client methods?
The text was updated successfully, but these errors were encountered:
If you just need the handling of !response.ok, then this is what I am doing:
constclient=hc<AppType>('',{fetch: async(...args: Parameters<typeoffetch>)=>{constresponse=awaitfetch(...args);if(!response.ok)thrownewError('Response not OK');returnresponse;}});
But there should be dedicated functionality for this so we can modify the response like you are doing and keep everything typesafe.
What is the feature you are proposing?
It would be great if the
options
of thehc()
would allow to add a custom response parser to centralize common code that we want to be executed on every response, e.g.:our current solution is to wrap every client call with a custom method that checks for errors and converts to json, e.g.
parseResponse(await client.myEndpoint.$get())
Would it be feasible to implement this as it will likely complicate typing the client methods?
The text was updated successfully, but these errors were encountered: