How to chain useQuery calls? | Use result from one query as input for another?
How can I achieve something like this?
14 Replies
But, you could probably make your backend handle this instead of doing 2 queries.
yea, chances are you want this to be one query that makes two database requests
round trips are expensive
Of course, but in my specific case i am mapping the first query with data that is only available client and i don't want it to be passed to the server
So the second query takes in information that the backend should not have?
Im still running into an issue, tho:
yup
Of course it's undefined if you destructured it
Just use the ? operator btw
Not working, because ids cant be undefined / null
And it's firstQuery?.ids, there is no data property if you copied my code
no i didn't destruct it
👍
Just gotta tell TypeScript to shut up then
but it leads to a runtime error
What if you pass a default that fits the requirements
never mind sorry
you are absolutely right with ? it worked
and it's just typescript complaining
Thank you very much
No worries