Here is the given code snippet:
signIn(email, password) {
let result = true;
firebase.auth().signInWithEmailAndPassword(email, password).catch(error => result = false);
waits(100);
return result;
}
I have a service that includes the above method, but the return statement executes before retrieving data from firebase. How can I resolve this issue?
SOLUTION
login.component.ts
login() {
this.loggedService.signIn(this.email, this.password).then(value => {
console.log(value);
if (value.user !== undefined) {
this.loggedService.logged = true;
this.router.navigateByUrl('account');
console.log(1);
}
}).catch(error => {
console.log(error);
});
}
logged.service.ts
signIn(email, password) {
return firebase.auth().signInWithEmailAndPassword(email, password);
}