Hi i am trying to get user details in angular and based on user values i need to perform specific task, i am able to make the call to the api but response is taking some time and thats why i am unable to check the condition.
ngOnInit() {
this.getUserDetails();
if(this.user.PrivacyNotice) //getting undefined here
{
}
else
{
}
}
getUserDetails() {
this.user.Email = "[email protected]";
this.bookingListSubscription =
this.restService.getUserProfile(this.user).subscribe(
data => {
this.user = data;
});
}
Here user is the object of type UserVM Model which contains PrivacyNotice boolean field
following is the service method which makes the api call
getUserProfile(user: UserVM): Observable<any> {
return this.http.post<UserVM>(this.getAPI('FetchUserProfile'),user,
this.httpOptions).pipe(
map(data => data),
catchError(this.handleError<any>('getUserProfile'))
);
}
in if i want to check the value of boolean flag PrivacyNotice which is returned from api so how can i achive this.