I am having difficulty grasping some of the concepts. Such as I have 
created a subscription to my SQL DB (users) upon login and I am able to 
present the data on the page (DOM). However, I a now trying to pull out 
specific data from the item to save for later use in my typescript file.

*login.component.ts*

this.usersService.getUsers() .subscribe((result: users) => (this.users[0] = 
result));

*users.service.ts*
public getUsers() : Observable<user[]> {       
     let userEmail = sessionStorage.getItem('userEmail');
     return this.http.get<user
[]>(`${environment.apiUrl}/${this.url}/${userEmail}`).pipe(
      tap((res:any)=>{
        sessionStorage.setItem('userRole', res.userRole;
        })
     ); 

This returns as expected and fills the following html. 

*login.component.html*
<div class="row" style="background-color:transparent;"> <mat-card 
*ngFor="let user of user" class="ecard"> 
<mat-card-title>{{user.role}}</mat-card-title> </mat-card> </div> 

However, I would like to use information from the 'user' to perform other 
functions in the ts file.

The TAP function is returning undefined and I do not understand why or how 
to correct this?

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/2313a684-6bf9-49cc-8ba5-985234395fa5n%40googlegroups.com.

Reply via email to