我正在尝试使用add.agent从uifx函数获取更新的消息变量。但是,wait函数和add.agent同时存在问题。
var message = "hi"; //test purpose
async function GetCertain_info(agent) {
console.log("1" + message);
await uiFx(); *//this works fine in the console.log, and it updates the message*
console.log("2" + message);
agent.add("Here are the information on " + message);*//this works when the await uiFx() is removed and the message variable is returned as its initial value "hi"*
}
async function uiFx() {
var {
ui
} = require('./uia.js');
return new Promise(function(resolve, reject) {
ui().then((msg) => {
console.log("Destination Message : " + msg)
message = msg;
resolve(message);
}).catch((msg) => {
console.log(msg)
message = msg;
reject(message);
})
});
}
问题是什么?如何解决?
谢谢你的帮助
暂无答案!
目前还没有任何答案,快来回答吧!