r/tanstack • u/Consibl • Apr 15 '25
Chained API calls
I’ve been banging my head against the wall for days trying to get chained API calls to work on Query.
I have an API call which provides an array of IDs I then have to use to make one API call per ID.
I have a separate API call which returns the equivalent data (directly) but from a different source.
I then want to combine the responses into one array of objects.
What would be the best way to chain the queries to be efficient and update as more responses come in?
5
Upvotes
1
u/ParrfectShot Apr 16 '25
Why is chaining needed here ? You can make these API calls for each ID in parallel and update the array when response is received in whatever state management solution you're using.
1
u/Secure_Banana3092 Apr 16 '25
Have you tried using the useQueries hook?
1
u/Imaginary_Treat9752 Jun 05 '25
I got the same question as you. What did you settle on u/consible?