Fetch data from nested json


my json is like this, and it always returns one record


how can i fetch the data without using the *ngFor?

ts file

      this.link = 'http://xxxx.com/apps/data2.php?action=get_posts&id='+this.id;

    //  alert(this.link);

      this.http.get(this.link).map(res => res.json()).subscribe(data => {
          this.post = data.records;


Sorry could you elaborate the problem a little more? Cant understand what you exactly need.

thanks for the reply!

my question is when i fetch the data using {{post.ID}} in home.html

i got error

Runtime Error
Uncaught (in promise): TypeError: Cannot read property ‘ID’ of undefined TypeError: Cannot read property ‘ID’ of undefined at Object.eval [as updateRenderer]

in your homePage be sure to initialise your post = {}. Then it will get populated after the async operation is done.

Check this thread we had a similar discussion here.

yeah! got it , thanks a lot !!!

1 Like