Let's say I have an async/await that calls an API that fetches all users.
async function getUsers() {
const users = await Api.getAllUsers()
return users.map(user => {
return {
id: user.id,
group: 'data depends on subsequent API call',
}
})
}
Within the return map, I have to do another API call to get some data that should be in the same scope.
const groupByUser = Api.getGroupByUserId()
How do I accomplish this? Can I put an async/await within the existing one? Do I create an array of all users ids and somehow map through that? I'm kind of lost on where to go next and any input would be appreciated.
// getUsers() passed into componentDidMount() wrapper