I am currently working with the following complex data structure:
[
{
"id": 1,
"houses": [
{
"id": 1,
"name": "house 1"
},
{
"id": 2,
"name": "house 2"
}
]
},
{
"id": 2,
"houses": [
{
"id": 3,
"name": "house 3"
}
]
}
]
In my project, I need to perform an asynchronous operation for each house in each user. To achieve this, I have a function that returns a promise and has the following signature:
sendWelcomeEmail(user, house)
While I am familiar with using Bluebird's Promise.map
when dealing with arrays of promises, my situation involves arrays of objects with nested arrays. What would be the correct approach to utilize Promise.map
in order to execute sendWelcomeEmail
for every user and house?