how can I invoke a trpc call inside a nested function?
I know it isn't directly possible. But is there a workaround?
7 Replies
Use the vanilla client
Will give you a promise to resolve
Solution
Set up a tRPC Client | tRPC
1. Install the tRPC Client library
Don't they normally do that? eg, api.posts.getAll.useQuery() in theo's t3 tutorial?
that is the trpc tanstack query client
with that you are able to handle the call in a more react way
with vanilla client you can use as if was plain ts
And react doesn't regard it as a hook?
no
Yeah, that did the trick. I just needed to do a little more data massaging of my stuff for everything to work.
Thank you very much!