I am encountering an issue in my console while attempting to extract data from an object nested within another object. I am uncertain about the correct method to map and return the necessary array of data, which is labeled as results
in this scenario.
Below is how the structure of my JSON file appears:
{
"count": 101,
"results": //an array[
object 1,
object 2,....
}
Here is my service call implementation:
getData(){
return this._http.get('url')
.map((res:Response) => res.json())
.catch(this.handleError);
}
Within my component file:
getData(){
this.service.getData().subscribe(
data => this.results = data,
error => this.errorMessage = <any>error
);
}
In the HTML file:
<tr *ngFor="let item of results">
<td><a style="cursor: pointer">{{item.title}}</a></td>
</tr>