-
-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature suggestion] "after" hook for Hono Client #928
Comments
Hi @yusukebe! Is there an ETA on this feature? Really want to implement a generic error handling method for all requests (or better said, responses). I saw you even opened a PR, but closed it in September. |
I closed that PR because we may have to implement hooks other than |
@yusukebe what do you think about doing it similarly to
|
It might not be perfect solution, but you can use a custom const client = hc<AppType>('http://localhost:3000', {
fetch: async (req: Request, init?: RequestInit) => {
return fetch(req, init)
.then((res) => res)
.catch((e) => {
console.error('Custom error message:', e)
}) as ReturnType<typeof fetch>
}
}) |
From discord. About Hono Client.
Sometimes we want to write a common handling when receiving responses.
Since it is tedious to write the same process every time, how about having a hook for when the response is received?
It can also be used to output logs, for example.
The text was updated successfully, but these errors were encountered: