I tried several ways to do this, but I think I have a bigger problem, because the class I use already has its functions defined.
I'm using the evilscan library and just want to export the 'ip'
but I am having problems with asynchronous functions and these promises
const Evilscan = require('evilscan'); const defaultGateway = require('default-gateway'); async function getIp(){ const options = { target:'192.168.0.1-254', port:'5000', status:'O', banner:true }; var ip = 0 const evilscan = new Evilscan(options); evilscan.on('result',data => { ip = data.ip }) evilscan.on('error', err => { throw new Error(data.toString()); }); evilscan.on('done', () => { return ip }) evilscan.run() } async function get(){ return getIp().then(function (params) { return params }); } var ip = get() console.log(ip)
https://stackoverflow.com/questions/66827291/getting-the-value-of-async-function March 27, 2021 at 09:47AM
没有评论:
发表评论