I should call an API then use it’s data as parameter for another request:
const { data, isLoading, error } = useQuery('fetchAvailableProducst', fetcher, { enabled: false });
const sendOrder = (categoryID) => {
const availableProducst = /* function to fetch a list of category */
const ids = [];
availableProducst.map(item => {
ids.push(item.id);
});
sendOrderMutation.mutate(ids);
}
the above code doesn’t work, I just written for mentioning to an idea… Actually I’m looking for a way to add something like await
before availableProducst
(which comes by useQuery()
) to get list then fill ids
and then call sendOrderMutation
to send order…
But is there any way to use await
for useQuery()
data?