I'm currently facing an issue where I need to await a response from my server in order to determine if an email is already taken or not. However, I am struggling to achieve this synchronously. TypeScript is indicating that the function isCorrectEmail() is of type void, which I can comprehend but cannot resolve. Any suggestions?
isEmailAvailable(){
return new Promise( (resolve, reject) => {
this.authService.checkemail(this.user.email).then(result => {
let res = <any> result;
if (res.code == 0){
resolve(true);
}
else resolve(false);
}, (err) => {
reject(false);
});
});
};
isCorrectEmail(){
this.isEmailAvailable().then( (result) => { return result ; } );
};
checkPersonalInfos()
{
if ( this.isCorrectEmail() == true){...}
..
}