I have nested arrays, I can get promises for a level 2 array, but I don't know how to implement top-level completion then.
result.forEach(function(entity){
return Promise.all(entity.urls.map(function(item){
return requestURL(item.href);
}));
});
for example, if it resultshas two or more elements, and each itemhas 10 or more URLs to retrieve, how to implement then [Promise.all][1]for all promises. Natural solution please.
Mostly for the proper handling of nested promises arrays.
Data structure:
var result = [
{
urls: [
{href: "link1"},
{href: "link2"},
{href: "link3"}
]
},
{
urls: [
{href: "link4"},
{href: "link5"},
{href: "link6"}
]
}
];
source
share