I'm using 3 region and using a aws configuration for output Timestamp and Average.
But I don't understand why I have a empty array in my output.
I add the different configuration, share cw object and getMetricStatistics method details.
I don't understand the method for response asynchronous call
Thanks for you help
var arr = [
    { "region": "eu-west", "value": "http://****" },
    { "region": "eu-west", "value": "http://****" },
    { "region": "eu-west", "value": "http://****" },
    ] ;  
var GlobalTab = [];
var r=-1;
    while ( arr[++r] ) {
    var region= arr[r].region; //test
    var Value = arr[r].value ; //test
    cw.getMetricStatistics(params, function(err, data) {
        if (err){
            console.log(err, err.stack); // an error occurred
        }
        else {   
            var TabJSON = [];
            for(var i=0;i<5;i++) {
                TabJSON.push(data.Datapoints[i]);
            }
        GlobalTab.push(TabJSON);
        function foo(){
        return new Promise( (resolve, reject) => { 
        setTimeout ( function(){    
        resolve(GlobalTab)// 
        }, 1000 )
        })
        }
        }
    });
}
console.log(GlobalTab); //error empty array
let bar ; 
foo().then( res => {
bar = res;
console.log(bar) // 
});
Expected result:
[[{Timestamp: 2019-01-15T08:26:00.000Z, Average: 200},
{Timestamp: 2019-01-15T08:32:00.000Z, Average: 200},
{Timestamp: 2019-01-15T08:26:00.000, Average: 200},
{Timestamp: 2019-01-15T08:29:00.000Z, Average: 200},
{Timestamp: 2019-01-15T08:35:00.000Z, Average: 200}],
[{Timestamp: 2019-01-15T08:26:00.000Z, Average: 200},
{Timestamp: 2019-01-15T08:32:00.000Z, Average: 200},
{Timestamp: 2019-01-15T08:26:00.000, Average: 200},
{Timestamp: 2019-01-15T08:29:00.000Z, Average: 200},
{Timestamp: 2019-01-15T08:35:00.000Z, Average: 200}],
[{Timestamp: 2019-01-15T08:26:00.000Z, Average: 200},
{Timestamp: 2019-01-15T08:32:00.000Z, Average: 200},
{Timestamp: 2019-01-15T08:26:00.000, Average: 200},
{Timestamp: 2019-01-15T08:29:00.000Z, Average: 200},
{Timestamp: 2019-01-15T08:35:00.000Z, Average: 200}]]
 
    