I tried below code
this.http.get(this.URL+this.categoryID)
.map(res => res.json())
.subscribe(data => {
// we've got back the raw data, now generate the core schedule data
// and save the data for later reference
this.items = data;
alert (this.items.id) // Showing undefined
});
How to fix can you please help me.
Below is my json response
{"id":10,"date":"2017-08-21T05:32:33","date_gmt":"2017-08-21T05:32:33","guid":{"rendered":"mysite/ionic2/sumitdemo/quotes/?p=10"},"modified":"2017-08-21T05:45:11","modified_gmt":"2017-08-21T05:45:11","slug":"man-needs-difficulties","status":"publish","type":"post","link":"mysite/ionic2/sumitdemo/quotes/man-needs-difficulties/","title":{"rendered":"Man needs difficulties"},"content":{"rendered":"<p>“Man needs difficulties in life because they are necessary to enjoy the success.” </p>\n","protected":false},"excerpt":{"rendered":"<p>“Man needs difficulties in life because they are necessary to enjoy the success.”</p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"quote","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"mysite/ionic2/sumitdemo/quotes/wp-json/wp/v2/posts/10"}],"collection":[{"href":"mysite/ionic2/sumitdemo/quotes/wp-json/wp/v2/posts"}],"about":[{"href":"mysite/ionic2/sumitdemo/quotes/wp-json/wp/v2/types/post"}],"author":[{"embeddable":true,"href":"mysite/ionic2/sumitdemo/quotes/wp-json/wp/v2/users/2"}],"replies":[{"embeddable":true,"href":"mysite/ionic2/sumitdemo/quotes/wp-json/wp/v2/comments?post=10"}],"version-history":[{"href":"mysite/ionic2/sumitdemo/quotes/wp-json/wp/v2/posts/10/revisions"}],"wp:attachment":[{"href":"mysite/ionic2/sumitdemo/quotes/wp-json/wp/v2/media?parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"mysite/ionic2/sumitdemo/quotes/wp-json/wp/v2/categories?post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"mysite/ionic2/sumitdemo/quotes/wp-json/wp/v2/tags?post=10"}],"curies":[{"name":"wp","href":"https://api.w.org/{rel}","templated":true}]}},{"id":8,"date":"2017-08-21T05:32:05","date_gmt":"2017-08-21T05:32:05","guid":{"rendered":"mysite/ionic2/sumitdemo/quotes/?p=8"},"modified":"2017-08-21T05:45:01","modified_gmt":"2017-08-21T05:45:01","slug":"all-birds-find-shelter-during-a-rain","status":"publish","type":"post","link":"mysite/ionic2/sumitdemo/quotes/all-birds-find-shelter-during-a-rain/","title":{"rendered":"All Birds find shelter during a rain"},"content":{"rendered":"<p>“All Birds find shelter during a rain. But Eagle avoids rain by flying above the Clouds.” </p>\n","protected":false},"excerpt":{"rendered":"<p>“All Birds find shelter during a rain. But Eagle avoids rain by flying above the Clouds.”</p>