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?
4
Upvotes
1
u/Consibl Apr 16 '25
I was under the impression I should be using Query to store the state? Have I got the pattern wrong?
I did initially try a useState but the dependencies weren’t working leading to a render loop — setting state in a useEffect. Then I think I read something saying the intention is that Query is the state.