Good morning, please I'm trying to return array value from function... but it always result in undefined when I try to use any value of the array like GetASN('128.101.101.101').autonomousSystemNumber and promise { } when I try to return the whole array...
please note that I tried these methods too but it didn't work...: https://stackoverflow.com/a/61719247/8704593 https://stackoverflow.com/a/51882019/8704593
async function GetASN(ipaddress) {
if(validateIPAddress(ipaddress) == false) return null;
let GeoResponse = {};
GeoIPReader.open(path.join(__dirname, 'databases/GeoLite2-ASN.mmdb')).then(await function (reader) {
GeoResponse = reader.asn(ipaddress);
console.log(GeoResponse.autonomousSystemNumber);
console.log(GeoResponse.autonomousSystemOrganization);
});
return GeoResponse;
}