@strawberry-3-141 thank you for your fast and competent answer.
This is what i did now:
......
request ( {
url: url,
method: 'GET'
},
function (error, response, body) {
var result = JSON.parse(body);
var warningData = [];
for (var regionId in result['alarms']) {
if (result['alarms'][regionId]['regions'][0]['name_de'] == region) {
var warnings = new Object();
warnings.start = result['alarms'][regionId]['valid_from'];
warningData.push(warnings.start);
warnings.end = result['alarms'][regionId]['valid_to'];
warningData.push(warnings.end);
warnings.regionName = result['alarms'][regionId]['regions'][0]['name_de'];
warningData.push(warnings.regionName);
warnings.level = result['alarms'][regionId]['priority']
warningData.push(warnings.level);
warnings.type = result['alarms'][regionId]['code']
warningData.push(warnings.type);
warnings.altitudeStart = undefined;
warningData.push(warnings.altitudeStart);
if (warnings.type == 1){warnings.event = "Frost";}
else if (warnings.type == 2){warnings.event = "Gewitter";}
else if (warnings.type == 3){warnings.event = "Grossflächige Glätte";}
else if (warnings.type == 4){warnings.event = "Kräftiger Regen";}
else if (warnings.type == 5){warnings.event = "Schnee";}
else if (warnings.type == 6){warnings.event = "Sturm";}
else if (warnings.type == 7){warnings.event = "Hochwasser";}
warningData.push(warnings.event);
warnings.headline = result['alarms'][regionId]['de']['title'];
warningData.push(warnings.headline);
warnings.description = result['alarms'][regionId]['de']['paragraph'];
warningData.push(warnings.description);
}
}
self.sendSocketNotification('WARNINGS_DATA', {warnings: warningData, region: region});
console.log(warnings);
console.log(warningData)
});
.......
Now i got the following outputs:
// With console.log(warnings);
{ start: '2017-01-16T21:00:00.000Z',
end: '2017-01-19T00:00:00.000Z',
regionName: 'Seeland/Bielersee',
level: 1,
type: 6,
altitudeStart: undefined,
event: 'Sturm',
headline: 'Starke Windböen',
description: 'eisige Bise. 21 Uhr bis Do 00 Uhr' }
// With console.log (warningData)
[ '2017-01-17T00:00:00.000Z',
'2017-01-18T23:00:00.000Z',
'Seeland/Bielersee',
1,
3,
undefined,
'Grossflächige Glätte',
'Gefahr von grossflächiger Glätte',
'durch Schneeglätte. Di 00 Uhr bis Mi 23 Uhr',
'2017-01-16T21:00:00.000Z',
'2017-01-19T00:00:00.000Z',
'Seeland/Bielersee',
1,
6,
undefined,
'Sturm',
'Starke Windböen',
'eisige Bise. 21 Uhr bis Do 00 Uhr' ]
My Problem now is that my Output is still looking different than his output. And when i get 2 warnings for the same Region the Output goes into the same Array… By the Way… Why i get only one Warning for the region with console.log(warnings);
Here is the Output example of his module:
[ { start: 1484586000000,
end: 1484650800000,
regionName: 'Kreis Harburg',
.....
state: 'Niedersachsen'
},
{ start: 1484586000000,
end: 1484650800000,
regionName: 'Kreis Harburg',
.......
state: 'Niedersachsen'
}
]