I am trying to return a variable and another promise from within a promise:
aPromise(url)
.then((response) => {
return Promise.all(
response.map((response) => {
return {id: response.id, response: aPromise(response.url)};
}
})
.then((data) => {
// do something with data.id and data.response}
}
In this example data.id is accessible but the promise data.response has not resolved. however if I return only the apiRequest(response.url) promise from the .map() then it does resolve.
the output of data should match =
[
{id:'123', response: {...},
{id:'456', response: {...},
...
]