Fetching different server url than defined in config
Is it possible to access the reactQuery instance and fetch different server url? I would like to use reactQuery to get data from my server which is at say
/address-middleware
instead of hitting /trpc/....
Can I do that? I dont want to setup separate reactquery provider or something just to call one separate endpoint3 Replies
Yes you can use React Query
but how I could fetch different url than the one which is defined via createTRPCReact -> /trpc
A query function can fetch any way you desire. See the Tanstack Query useQuery docs for examples. On the tRPC side, everything you need to know should be here (mostly relevant is the example of getting the query client)
https://trpc.io/docs/useContext#helpers
useContext | tRPC
useContext is a hook that gives you access to helpers that let you manage the cached data of the queries you execute via @trpc/react-query. These helpers are actually thin wrappers around @tanstack/react-query's queryClient methods. If you want more in-depth information about options and usage patterns for useContext helpers than what we provide...