Best Practices for 3rd party api call

In my case I have a call to a goecode endpoint to turn and address to coordinates.
But I will have some cloudinary call I will want to make soon. Would it be best to funnel that call through trpc and use node fetch to make the call? Or would it make more sense to use react query on the front end and have the user make the call? Currently I am doing a simple fetch on the front end triggered by a button click. Thought I was see if there is a general best practice with T3.
10 Replies
Samathingamajig
if the thirdparty needs an api key of some kind, create a trpc endpoint and fetch it on the backend if it doesn't, just call it on the frontend with react-query. it's even better if they have an sdk or types available
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Samathingamajig
oh yeah also if the request would be blocked by CORS, you'd need to set up the trpc endpoint
dustatron
dustatronOP2y ago
If I want to use react query on the front end do I need to install the offical react query version?
Samathingamajig
you should
dustatron
dustatronOP2y ago
Gotcha. Thanks for the advice. So far I have been super impressed with T3
Samathingamajig
technically its already a dependency of trpc (i think) so you should already be able to import it
dustatron
dustatronOP2y ago
I feel like I tried and I got a ts error
Samathingamajig
but in general you should promote it to being a dependency of your project if you use it yourself
dustatron
dustatronOP2y ago
Oh, I should move it in the package.Json that makes sense
Want results from more Discord servers?
Add your server