I need to make two different API calls and perform calculations based on the results of both. To wait for both promises to resolve, I am using Promise.all().
const getHashTagList = async () => {
loader.start();
try {
await getAllHashTags().then((response) => {
setHashtagList([...response?.data]);
});
} catch (err) {
} finally {
loader.stop();
}
};
const getUserFollowingHT = async () => {
loader.start();
try {
await getUserDetails().then((response) => {
setUserFollowingHT([...response?.data?.followingHashtags]);
});
} catch (err) {
} finally {
loader.stop();
}
};
To call these 2 promises, I am using the following syntax:
useEffect(() => {
//getHashTagList();
// getUserFollowingHT();
Promise.all([getHashTagList, getUserFollowingHT]).then(
(combineResp) => {
console.log(combineResp);
}
);
}, []);
However, I am encountering a problem where the output shows function declaration syntax instead of calling those promises successfully.