I am currently facing a challenge in extracting a specific array element from a JSON response that I have retrieved. While I can successfully fetch the entire feed, I am struggling to narrow it down to just one particular element.
Here is what my service controller looks like so far:
getJsonData(){
return this.http.get('https://www.reddit.com/r/worldnews/.json').map(res => res.json());
}
On my page, my code snippet is as follows:
getdata() {
this.HttpModule.getJsonData().subscribe(
result => {
this.News= result.data.children(1);
console.log("success:"+this.News);
},
err => {
console.error("Error : "+err);
},
() => {
console.log("getData completed");
}
);
}
I thought the correct method was children
, but when I attempted children(1)
out of trial and error, it did not produce the desired outcome.