Mugetsu
Mugetsu2y ago

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 endpoint
3 Replies
mark salsbery
mark salsbery2y ago
Yes you can use React Query
Mugetsu
MugetsuOP2y ago
but how I could fetch different url than the one which is defined via createTRPCReact -> /trpc
mark salsbery
mark salsbery2y ago
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...

Did you find this page helpful?