Query parameter based on another useQuery
So, I have two
useQuery calls, the first one gives me an id, I insert that same id into the second useQuery function so that it will get passed as a query parameter, however, since it's initially undefined, the request that fires has the query parameter as undefined, console.log also logs undefined first and then the correct value, how do I get around this?
1 Reply
genetic-orange•4y ago
seems like a standard dependent query where you'd disable the second query until you have all the necessary inputs?
https://tanstack.com/query/v4/docs/guides/dependent-queries
Dependent Queries | TanStack Query Docs
Dependent (or serial) queries depend on previous ones to finish before they can execute. To achieve this, it's as easy as using the enabled option to tell a query when it is ready to run:
`tsx