How can I get into this promise? When I try get data from my api in this way and use function setComments(commentsFromDb) I get array of promises, each of them is fulfilled and contain correct object. How can I get this object from these promises?
useEffect(() => {
const resp = async () => {
const response = await getComments().then((commentsFromDb) => {
commentsFromDb = commentsFromDb.map(async (comment) => {
comment.author = await getAuthor(comment.authorId);
return comment;
});
return commentsFromDb;
}).then((commentsFromDb) => setComments(commentsFromDb));
};
resp();
console.log(comments);
}, []);