I have an initial usePaginatedQuery which gives me an array of ids:
const {
resolvedData: policies,
isLoading,
isError,
} = usePaginatedQuery(
[`policies`],
() => {
return axios.get(`/v1/policies?page=${page}`);
},
{
enabled: isEnabled,
retry: false,
}
);
I need to iterate over the id in the resolved data array to subsequently fetch data associated with that id:
usePaginatedQuery(
[`policy.${id}.documents`],
() => {
return axios.get(
`/v1/policies/${id}/documents?page=${page}`
);
},
{
enabled: isEnabled,
retry: false,
}
);
I then need an array of documents that are associated with the appropriate id to build my react-table e.g.
[{id: '123', documents: ['foo.txt', 'bar.txt']}, {id: '456', documents: ['xxx.txt', 'yyy.txt']}]
Is there a way to do this in react-query?
I looked at documentation for dependant queries but it is not quite what i need.
I have an initial
usePaginatedQuerywhich gives me an array of ids:I need to iterate over the
idin the resolved data array to subsequently fetch data associated with that id:I then need an array of documents that are associated with the appropriate id to build my
react-tablee.g.[{id: '123', documents: ['foo.txt', 'bar.txt']}, {id: '456', documents: ['xxx.txt', 'yyy.txt']}]Is there a way to do this in
react-query?I looked at documentation for dependant queries but it is not quite what i need.