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.
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
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•2y ago
Message Not Public
Sign In & Join Server To View
oh yeah also if the request would be blocked by CORS, you'd need to set up the trpc endpoint
If I want to use react query on the front end do I need to install the offical react query version?
you should
Gotcha. Thanks for the advice. So far I have been super impressed with T3
technically its already a dependency of trpc (i think) so you should already be able to import it
I feel like I tried and I got a ts error
but in general you should promote it to being a dependency of your project if you use it yourself
Oh, I should move it in the package.Json that makes sense