【发布时间】:2023-02-07 01:35:59
【问题描述】:
数据由数据库中不同用户发布的一系列帖子组成。每个帖子都包含发帖用户的 _id。我想映射每个帖子,获取帖子的 _id 并获取每个帖子的用户数据。这就是我取得的进展。有没有正确的方法或更好的方法?我遇到了错误。
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);
});
});
};
【问题讨论】:
标签: javascript reactjs arrays axios