I have an Angular based application that is making a RESTful request to a server whose response is a JSON stream that represents a list of objects of the following type:
export interface Personal {
theAddress: string;
theCity: string;
theState: String;
theCountry: string;
emailAddress: string;
}
The code within my component uses an HttpClient GET request to get data to place into an Observable:
people$: Observable<Personal[]>;
...
ngOnInit() {
this.people$ = this.http
.get<Personal[]>("/people/get")
.map(data => _.values(data))
.do(console.log);
}
For various reasons, I would like to extract the contents of the Observable and put them into an array of people objects. After reading various documentation on the Internet, I am aware that to extract the data received I need to somehow use a subscribe method on the Observable. Unfortunately, it is unclear to me exactly how to do this.
Can someone help with this? How does one extract the objects received by an Observable into an array?