typescript - Ionic App 中的 TypeScript 错误:无法在 Firebase 登录中使用异步
问题描述
在我的 ionic 应用程序中,我正在尝试创建一个注册代码,该代码将检查数据库中的重复条目,如果没有找到重复条目,它将允许用户使用电子邮件和密码创建帐户。当用户想要注册时,他/她必须提供用户数据和唯一的 GroupID,如果此 GroupID 在数据库中已经可用,则用户无法使用该 GroupID 注册。
async signup(): Promise<void> {
this.checkValidEmail(this.user.email, (isError) => {
if (isError) {
console.log("Error : Already has this email address ");
this.error = "Already has this email address in out system";
} else {
this.checkValidGroup(this.user.GroupName, (isError1) => {
if (isError1) {
console.log("Error : Thid Group Id is already Taken ");
this.error = "This Group ID is not available";
}
// this.userService.pushUser(this.user);
else if (this.matchPassword(this.user)) {
console.log("Error :Don't metch password");
this.error = "Don't metch between Password and confirm password";
} else if (this.user.password.length < 6) {
console.log("Error : passwrod short");
this.error = "Password is too short (minimum is 6 characters).";
} else {
this.deleteconfirm(this.user);
var pass = Md5.hashStr(this.user.password);
this.user.password = pass.toString();
var pin = Md5.hashStr(this.user.passcode);
this.user.passcode = pin.toString();
const loading: Loading = this.loadingCtrl.create();
loading.present();
const email = this.user.email;
const password = this.user.password;
try {
const signup: firebase.User = await this.authProvider.signup(
email,
password
);
await loading.dismiss();
if (this.userService.pushUser(this.user)) {
this.navCtrl.setRoot(TabsPage);
this.navCtrl.push(TabsPage);
}
} catch (error) {
await loading.dismiss();
const alert: Alert = this.alertCtrl.create({
message: error.message,
buttons: [{
text: 'Ok',
role: 'cancel'
}]
});
alert.present();
}
}
});
}
});
}
但是这段代码显示了一些错误,例如
Cannot find name 'await'.
有Property 'signup' does not exist on type 'AuthProvider'.
什么帮助吗?