Data consists of an array of posts made by different users in the database. Each post holds the _id of the user who made the post. I want to map through each post, get the _id of the post and fetch the user data for each post. this is how far I've gotten. is there a proper way to do this or a better way? I'm running into errors.
const getUsers = () => {
data.map(async () => {
await axios({
method: "POST",
withCredentials: true, url:`https://droplikebackend.herokuapp.com/api/user/get/${id}`,
data: {
userId: data.userId,
},
})
.then((res) => {
console.log(res.data);
})
.catch((err) => {
console.log(err);
});
});
};