should i just make a REST api for that?

i have a simple function: isTrueOrFalse it returns true or false depending on how the server feels If i understand this correctly, with tprc and useQuery, i have to create a hook that hits the server on every render.. but i just want to hit the server on a function call... im thinking TRPC is not the droid im looking for? just make a simple rest api?
6 Replies
Brendonovich
Brendonovich16mo ago
Nothing is forcing you to use useQuery, u can just call query on the client directly - https://trpc.io/docs/vanilla
Vanilla client | tRPC
The magic of tRPC is making strongly typed API calls without relying on code generation. With full-stack TypeScript projects, you can directly import types from the server into the client! This is a vital part of how tRPC works.
Brendonovich
Brendonovich16mo ago
U could also use a useQuery and modify the refetch behaviour idk much about that tho
.hatulapro
.hatulapro16mo ago
useQuery doesn't call the server on every render. It only calls when it "needs" to (depending on how you configure it). But if you only want to make a request on an event, that's what useMutation is for
fotoflo
fotoflo16mo ago
didnt know about the vanilla client trpc syntax is obtuse really annoyingly obtuse. i wonder if its intentinal
Brendonovich
Brendonovich16mo ago
what about it do you find obtuse?
fotoflo
fotoflo16mo ago
createTRPCProxyClient takes an object with a links array. the links array is comprised of objects returned by httpBatchLinks, which takes an object and the object is a url.... if you boil it all down, you just have an array of urls? Or only one URL is required? in which case we nest a single url for config inside 4 layers of config
Want results from more Discord servers?
Add your server
More Posts