I'm stuck with a problem. I have a object with a array of objects inside and I want to iterate through it and in each array I get I want specific positions.
So I want for the first element to get the [0], the second I want [0], the third I want [2] and the last element I want [0].
values ************** [ anonymous { medium: [ 0.28, 0.26, 0.13 ] },
4|wscontro | anonymous { medium: [ 13.51, 0.04, 0.75 ] },
4|wscontro | anonymous { medium: [ 1527.58, 262.98, 27.4, 59.49 ] },
4|wscontro | anonymous { medium: [ 60305.25, 0 ] } ]
4|wscontro | values type of -------- object
4|wscontro | values ************** [{"medium":[0.28,0.26,0.13]},{"medium":[13.51,0.04,0.75]},{"medium":[1527.58,262.98,27.4,59.49]},{"medium":[60305.25,0]}]
4|wscontro | item ---->>> anonymous { medium: [ 0.28, 0.26, 0.13 ] }
4|wscontro | item ---->>> anonymous { medium: [ 13.51, 0.04, 0.75 ] }
4|wscontro | item ---->>> anonymous { medium: [ 1527.58, 262.98, 27.4, 59.49 ] }
4|wscontro | item ---->>> anonymous { medium: [ 60305.25, 0 ] }
And I want to get
0.28, 13.51, 27.4, 60305.25
I dont know how to get the index of the key with my forEach.
my code:
var allPromises=[];
allPromises.push(Database.Alerts.getDeviceSystemByDeviceId("system.load", device.id));
allPromises.push(Database.Alerts.getDeviceSystemByDeviceId("disk_space.sda3", device.id));
allPromises.push(Database.Alerts.getDeviceSystemByDeviceId("system.ram", device.id));
allPromises.push(Database.Alerts.getDeviceSystemByDeviceId("platform.temperatures", device.id));
Promise.all(allPromises).then(function(values){
console.log("values **************", values);
console.log("values type of --------", typeof(values));
console.log("values **************", JSON.stringify(values));
values.forEach(function(item){
console.log("item ---->>> ", item);
});
["a","b","c"].forEach((a, ix) => { console.log(a, ix); })would show aa 0, b 1, c 2