The general situation is as follows:
First obtain an array (regions) from a request, ignore this step, it has been processed previously;
Traverse this array to obtain the required information. This allows N asynchronous requests to be sent.
Process the returned data after all these asynchronous requests are completed.
The problem I encountered here is that every time it seems to go directly to the outer then method, shouldn't all the inner thens be resolved before entering the outer then method? How should I rewrite my question?
var promises = [];
promises = regions.map(function (region) {
return new Promise(function(resolve) {
Promise.all([asyncRequest1(region), asyncRequest2(region), asyncRequest3(region), asyncRequest4(region)])
.then(function (reses) {
resolve(reses);
});
});
});
Promise.all([promises]).then(function(results) {
handle(results);
});