How can I access to a second level information in a JSON response with RxJs library?

Viewed 32

The SelectAllPaged(UserQ) method returns an Observable that contains the response of an API that query users from a table. To this Observable I execute the subscribe() method to take the response and make it as interface type IUserQ (1st level of the JSON content). What I need, in addition to the information of the 1st level, is the information contained in the 2nd level, that is, the list of users, lstUser, which respects the IUser interface.

I attached an inspection here, Debugging an RxJS observable, that I did during debugging on the UserQ constant. Any info helps me, thanks!

1 Answers

You can map your response using map operator

import { map } from 'rxjs/operators';

SelectAllPaged(UserQ).pipe(
  map((response:IUserQ) =>  response.lstUser)
).subscribe((usersList:IUser[]) => console.log("users list", usersList ))
Related