【发布时间】:2019-08-16 08:56:19
【问题描述】:
以前我是这样使用的:
现在,按照node 10 更新了模块。
所以,需要帮助来整合它。
const maxmind = require('maxmind');
exports.getIsoCountry = function(pIpAddress) {
modules.debugLog('inside getIsoCountry : ',pIpAddress);
maxmind.open(sGlAppVariable.maxmindDbPath)
.then(function(lookup) {
var ipData = lookup.get(pIpAddress);
//console.log(ipData);
console.log('iso_code',ipData.country.iso_code);
return ipData.country.iso_code;
});
}
console.log(getIsoCountry('66.6.44.4')); 它应该打印国家代码。但它总是undefined。因为这是一个承诺。
如何调用这个getIsoCountry函数?
任何帮助将不胜感激。
【问题讨论】:
标签: javascript node.js promise maxmind