我有一个通过FireBase向用户签名的方法。我有一个承诺,当它完成,然后,我得到了令牌。
signinUser(email: string, password: string) {
return firebase.auth().signInWithEmailAndPassword(email, password)
.then(
response => {
this.router.navigate(['/']);
firebase.auth().currentUser.getIdToken()
.then(
(token: string) => {
this.token = token
}
)
}
)
.catch(
error => console.log(error)
);
}
现在,我从另一个文件调用这个方法,我想在signinuser方法完成它的承诺后做些什么。
onSignin(form: NgForm) {
const email = form.value.email;
const password = form.value.password;
this.authService.signinUser(email, password)
.then(
res => console.log(res)
)
}
我得到的结果是未定义的。为什么?