I have a simple useEffect in my component to fetch data from 3 API calls:
useEffect(() => {
Promise.all([
fetch(`${baseUrl}/counts?entity=color`),
fetch(`${baseUrl}/counts?entity=brand`),
fetch(`${baseUrl}/counts?entity=category`)
]).then(([x, y, z])=> {
console.log(x.json(), y.json(), z.json());
});
}, []);
I'm expecting the actual data I get from the API so that I can use it in my UI, but instead I'm getting this:
I've also tried doing this:
useEffect(() => {
Promise.all([
fetch(`${baseUrl}/counts?entity=color`),
fetch(`${baseUrl}/counts?entity=brand`),
fetch(`${baseUrl}/counts?entity=category`)
]).then(responses => responses.map(r => r.json()))
.then(([x, y, z])=> {
console.log(x, y, z);
});
}, []);
I see the desired value inside PromiseResult
, but I'm not sure how to extract it:
What am I doing wrong here. How do I access the array in my code?