const {
isLoading,
data: products,
refetch,
} = useQuery(["products"], () =>
axios.get(
`https://product-bazar.herokuapp.com/api/v1/public/product`
)
);
How can I destruct data from data in this query operations ex:[data?.products]
You can destruct the nested data from response data. example given below:
const { isLoading, data: products, refetch, } = useQuery(["products"], () => axios.get( https://product-bazar.herokuapp.com/api/v1/public/product ).then((res) => res.data?.products));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.