//Client.js
var CON,FUNC;
class FUNCS {
constructor() {}
async createAccount(coinId){
await new Promise(function(resolve, reject) {
CON.openAccount(coinId).then(response => {
console.log(response); //returns undefined
resolve(response);
})
});
}
}
class CONNECTION {
constructor() {this.socket = io.connect()}
async openAccount(id){
await Promise.resolve(this.socket.emit('openAccount',{'id':id},function (rs) {
return rs;
}));
}
}
CON = new CONNECTION(),FUNC = new FUNCS();
//index.html
<span onClick="FUNC.createAccount()"></span>
app.js
socket.on('openAccount',function (id,fn) {
setTimeout(function () {
fn('seee');
},3000)
});
how can i catch callback from app.js in FUNCS.createAccount's console Because its giving undefined
CON.openAccount(coinId).then(response => {
**console.log(response);//returns undefined;**
resolve(response);
})