I have a function that retrieve data of one user. Now I want to get in this function the user_id like that:
this.storage.get(USER_ID).then(val => {
this.id = val;
)}
so the api knows from which user it need the id. My main function I have to insert this is:
ngOnInit() {
this.subscription = this.authService.authenticationStateSubject.pipe(
switchMap(isAuthenticated => {
if (isAuthenticated) {
return this.userService.getUserDetails(this.id);
} else {
return of(null);
}
}),
).subscribe(
result => {
if (result) {
this.information = result;
console.log(this.information);
} else {
}
},
error => {
}
);
}
I tried to put my snippet right after the if (isAuthenticated) {
but somehow it doesn't work with the two last brackets. Can I actually connect these two snippets?