I am new to ionic and facing issues related to Observable. I want to get data from http and show them on the view but I cant figure out how to get the view to display the data. Any help is appreciated, thanks.
Data From API
{
"success": true,
"data": [
{
"id": 1,
"name": "testst",
"purpose": "sale",
"address": "ddd",
"beds": 3,
"baths": 3,
"size": "3",
"price": 23,
"description": null,
"contact_details": "dsdfdsfsfd",
"status": "inactive",
"created_at": "2019-01-21 15:18:39",
"updated_at": "2019-02-28 08:44:25",
"deleted_at": null,
"images": []
},
{
"id": 2,
"name": "testst",
"purpose": "rent",
"address": "tsyetsyety",
"beds": 3,
"baths": 3,
"size": "3",
"price": 3,
"description": null,
"contact_details": "3432",
"status": "inactive",
"created_at": "2019-01-21 15:19:20",
"updated_at": "2019-01-21 15:19:20",
"deleted_at": null,
"images": []
},
{
"id": 3,
"name": "testst",
"purpose": "rent",
"address": "tsyetsyety",
"beds": 3,
"baths": 3,
"size": "3",
"price": 3,
"description": null,
"contact_details": "3432",
"status": "inactive",
"created_at": "2019-01-21 15:21:23",
"updated_at": "2019-01-21 15:21:23",
"deleted_at": null,
"images": []
}
],
"message": "Houses retrieved successfully"
}
Code from provider
getHousesData() {
return this.http.get(this.apiUrl+'/houses')
.map (results => {
results = results['data'];
results['data'];
});
}
Code from the page
houseslist: Observable<any>;
getHouses() {
this.houseslist = this.housesService.getHousesData();
this.houseslist.subscribe(data => {
console.log(data);
Object.keys(data).forEach(id => {
console.log('Key: ' + id);
});
}, err => {
console.log(err);
});
}