How do I create the interface so I can get the second level data in the
Json Object? As it is now the console log outputs [object object] when
there is nested object. I put comments where there are more values to get.
thanks,
---
interface PostsResponse {
posts:string[];
}
----
export class AppComponent implements OnInit {
constructor(private http: HttpClient) {}
ngOnInit(): void {
this.http.get<PostsResponse>
('https://public-api.wordpress.com/rest/v1.1/sites/idcdistro.wordpress.com/posts/?author=ajpRspthis&number=10&pretty=true').subscribe(data
=> {
console.log("id"+data.posts[0].ID);
console.log("URL"+data.posts[0].URL);
console.log("Site ID"+data.posts[0].site_ID);
console.log("Capabilities"+data.posts[0].categories);//content, date
console.log("Author"+ data.posts[0].author); //name
console.log("Discussion"+ data.posts[0].discussion);//exerpt, like_count
console.log("Modified"+ data.posts[0].modified);
console.log("Other URLs"+ data.posts[0].other_URLs);//short_URL,
site_ID, slug, status, sticky
console.log("Tags"+ data.posts[0].tags);//Christmas, Concerts, Holiday
Jam, Narada Michael Walden,Narada Michael Walden Foundation
console.log("Terms"+ data.posts[0].terms);
console.log("Title"+ data.posts[0].title);
console.log("Type"+ data.posts[0].type);
});
}
}
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.