when I'm trying to pass the values to an array and return them the console only shows an empty array or say undefined!
my problem is .then don't pass the value to the array
const net = require('net');
const find = require('local-devices');
class Network{
hostname : string = "";
port = 80 ;
deviceList: any = [];
public connect(): void{
if (net.isIPv4(this.hostname)){
var connection = net.createConnection({port : this.port, host : this.hostname});
console.log(connection);
}
}
public findDevices(){
var boom:object[] = [];
find().then((devices:any[])=>{
this.deviceList.push(devices);
})
return this.deviceList;
}
}
const monitor = new Network();
let data = monitor.findDevices();
console.log(data);