Skip to content

Difficulty with understanding Hono RPC. #3123

Answered by Meess
sureddibhargav asked this question in Q&A
Discussion options

You must be logged in to vote

It's actually way simpler, hc is super dumb and it's implementation doesn't know or code anything about the API (it's al just typings). So what it does when you do client.some.path.to.your.endpoint.$get() simplified:

  • it reads the name of what you try to access (done via javascript proxies, not to confuse with the proxy you want in your vite config to proxy to your backend), and puts it in an array, i.e. you get ["some", "path", "to", "your", "endpoint", "$get"]
  • then checks the last argument and sees if it starts with an $, if so it takes what's after the $ and makes that the method for your request (in this case "get" so it will be a get request).
  • Then it joins the rest with a /, so ["so…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@sureddibhargav
Comment options

@Meess
Comment options

Answer selected by sureddibhargav
@sureddibhargav
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants