The client — RPC · Hono

Wrap hc in a module the rest of an app can call: list(), find() and add() over the typed client, statuses narrowed into a Cat, a null or an ApiError, and a base URL that tests and production both pass in.

What you will learn

Read the theory for The client

All RPC lessons

All Hono courses

loading types…

What you'll learn

  • Narrow a client response on res.status so json() is typed as the body of that status
  • Wrap hc in a module that takes the base URL and ClientRequestOptions, so a test can inject fetch
  • Turn an API's refusal into a return value or an error that carries the status and the message