I am trying to import data from json file in my Angular 5 ionic project, but I cant because I am getting error : TS2339: property results does not exist on type 'Object' which is in home.ts (2 of them)
Provider : people.ts
getPeople() {
return this.http.get('http://www.json-generator.com/api/json/get/cghlMAGJvm?indent=10')
}
}
home.ts
constructor(public navCtrl: NavController,
public service: People)
{
this.service.getPeople()
.subscribe(
data => this.people = data.results
)
}
toggleReorder(){
this.shouldReorder = !this.shouldReorder
}
doRefresh(e){
this.service.getPeople()
.subscribe(
data => this.people.unshift(...data.results),
err => console.log(err),
() => e.complete()
)
}
}
As I saw in angular/http guide there should be like that :
showConfig() {
this.configService.getConfig()
.subscribe(data => this.config = {
heroesUrl: data['heroesUrl'],
textfile: data['textfile']
});
}
But I want to copy all the data not only few parts. What is the right way of doing it ?