I want to push the results from a promise function into an array however, the array remains empty. Can someone help pleaseThis is what I would like to achieve at the end, update my ejs file from the promise function. However, nothing happens once I do this.
var Data = [];
raw.forEach(function (host) {
ping.promise.probe(host.ip).then(function (res) {
if(res.alive){
const input = {
"Host": i.host,
"IP": i.ip,
"Status": "Alive",
"Avg": res.avg
}
Data.push(input);
}
else {
const input = {
"Host": i.host,
"IP": i.ip,
"Status": "Dead",
"Avg": res.avg
}
Data.push(input);
}
});
});
console.log(Data);