I am obtaining data after making multiple fetch requests through chaining. I want to display the data on the page in the form of a table. But when I try to map over the object, iteration doesn't work.
useEffect(() => {
const getResources = async() => {
await getUserResourceId()
.then((data) => {
const resourceId = data.resourceId;
getPersonalGroup(resourceId)
.then((responseData) => {
personalGroup = responseData.result;
getPersonalGroupResourceId(personalGroup, 24)
.then((resourceData) => {
resourceData.forEach((resourceId) => {
getIndividualResourceId(resourceId)
.then((resources) => {
testData.push(resources);
console.log('resourceData', resources);
});
});
});
});
});
}
getResources();
}, []);
When I display testData, the result is :

Because testData has no value initially, the mapping is not working as well. So iterating over the data and displaying part is not working. How do I store the data, once all the pending resources are fetched ? Adding await is not helping.