我的阵列中有3个区域 我为每个区域显示5个JSON。 如何为5个JSON声明变量? 我为区域添加数组
var arr = [
{ "region": "eu-west", "value": "http://****" },
{ "region": "eu-west", "value": "http://****" },
{ "region": "eu-west", "value": "http://****" },
]
for (const key in arr) {
var region= arr[key].region
var Value = arr[key].value
cw.getMetricStatistics(params, function(err, data) {
if (err){
console.log(err, err.stack); // an error occurred
} else {
var status;
for(var i=0;i<5;i++){
console.log(data.Datapoints[i]);
// OUTPUT
/* (1) {Timestamp: "2019-01-15T08:26:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:32:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:26:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:29:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:35:00.000Z", Average: 200}
(2) {Timestamp: "2019-01-15T08:26:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:32:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:26:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:29:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:35:00.000Z", Average: 200}
(3) {Timestamp: "2019-01-15T08:26:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:32:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:26:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:29:00.000Z", Average: 200},
{Timestamp: "2019-01-15T08:35:00.000Z", Average: 200}
*/
}
//******* NEED *********
tabRg = [region1, region2, region3];
}
我的需求: