I have following code:
data:IQuest[]|any=[];
ngOnInit(){
this.getData();
console.log(this.data[1].Question);
}
getData(){     
  let url = "http://127.0.0.1:5153/Quests";
  this.http.get(url).subscribe(data=>{
  this.data=data;     
});
}
export interface IQuest {
Id: number,
lat: number,
lon: number,
Question:string,
}
I can't access values inside data property in typescript, for example when I call console.log, like in code above I'm getting error like this:
ERROR TypeError: Cannot read properties of undefined (reading 'Question')
at AppComponent.ngOnInit (app.component.ts:32:30)
On the other hand when I want to display values in html, they display properly and there is no problem with access, example:
<div *ngFor="let element of data">
  {{element.question}}
</div>
Which lists value of propertie one under another. So why can't I access those values in TypeScript?

this.datais empty when you call your console.log and thereforethis.data[1]is undefined. If you log for example in your subscribe method, it will work.IQuest[] | anyis exactly the same type asany. In factT | anyis exactlyanyfor any typeT. Code like that doesn't make any sense therefore.