Trying to call an async function from a Cordova plugin, but the await keyword doesn't seem to be working:
export class MationLiteService implements IgatewayService {
async getGroupAllInfo(gatewayId: string, account: string, decryptedpasswd: string) {
// some codes
return await cordova.plugins.MationPlugin.getGroupAllInfo(data, async (response) => {
const json: JSON = JSON.parse(response);
console.log('responseaaaaa:' + response);
return json;
}, (error) => {
console.log('error: ' + error);
});
}
}
This is the gateway manager class:
export class GatewayManagerService {
public getGroupAllInfo(gatewayType: string, gatewayId: string, account: string, decryptedpasswd: string) {
return this.gatewayFactoryService.getGateway(gatewayType).getGroupAllInfo(gatewayId, account, decryptedpasswd);
}
}
Here's how I'm calling it:
async getAllInfo2(){
this.facadaService.GetGatewayManagerService().getGroupAllInfo('mation-lite', this.zifan, 'admin', '5555').then((response) => {
console.log(response);
});
//await this.facadaService.GetGatewayManagerService().test('mation-lite');
}
When trying to print the response, it returns undefined.