Code:
reset(){
let alert = this.AlertCtrl.create({
buttons :['ok']
});
this.userservice.passwordreset(this.email).then((res: any)=>{
if(res.success){
alert.setTitle('Email sent');
alert.setSubTitle('please follow the instructions in the email to reset the password')
}
else{
alert.setTitle('failed');
}
})
}
Error:
property then does not exist on type void , A typescript error
can someone please help me by correcting this code snippet so that the 'then' function works cheers!
The issues here is with passwordreset()
function ,
It should look like this :
passwordreset(): Promise<any> {
// this should return a promise
// make sure , you are returning promise from here
return this.http.get(url)
.toPromise()
.then(response => response.json().data)
.catch(this.handleError);
}
You were returning the promise inside promise function , but not returning it from
passwordreset()
,
Please have a look at your code and updated code , you will get an idea
Your code :
passwordreset(email)
{
var promise = new Promise((resolve,reject)=>{
firebase.auth().sendPasswordResetEmail(email).then(()=>{
resolve({success :true});
})
.catch((err)=>{
reject(err);
})
return promise;
});
}
Updated Code :
passwordreset(email): Promise<any>
{
return new Promise((resolve,reject)=>{
firebase.auth().sendPasswordResetEmail(email).then(()=>{
resolve({success :true});
})
.catch((err)=>{
reject(err);
});
});
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加