I have an Angular function that I'm trying to test if the user is valid by comparing their credentials against the database:
isLoggedIn() {
this.userService.getUser(this.user.userName)
.pipe(first())
.subscribe(
result => {
this.currentUser = result;
if (this.currentUser.fullName != result.fullName) {
return false
}
return true;
},
() => { });
console.log('The function shouldn't go here')
}
How can I make the function wait for my subscribe to finish? Right now it's going straight through to the console.log line and returning false, and then getting the results back from the api call