问题描述
早上好, 请我尝试从函数返回数组值...但是当我尝试使用数组的任何值(如 GetASN('128.101.101.101') 时,它总是导致 undefined。当我尝试返回整个数组时,autonomousSystemNumber 和 promise { }...
请注意,我也尝试过这些方法,但没有奏效...: 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;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)