somefunction(){
isUserLoggedin(): boolean {
this.isUserInDB().subscribe((result: any) => {
if (result.code === 200) {
return true;
}
});
return false;
}
isUserInDB(): this API takes a token from localstorage and returns 200 if the user exists in DB or returns 404 if the user does not exist in DB (someone is trying to try his/her own token.)
In this scenario, I always end up receiving false because the first return statement gets executed before the subscribe method. Is there a different approach I should consider, or am I just overcomplicating things?