Recently, I started diving into Angular10 and encountered a challenge while trying to iterate through a JSON object.
The JSON object in question:
[
{
ID: "2",
testata: "Corriere.it - Homepage",
url: "http://xml2.corriereobjects.it/rss/homepage.xml",
categoria: "QUOTIDIANI"
},
{
ID: "3",
testata: "Open",
url: "https://www.open.online/feed/",
categoria: "NEWS"
},
{
ID: "4",
testata: "ANSA.it",
url: "https://www.ansa.it/sito/ansait_rss.xml",
categoria: "NEWS"
}
]
An excerpt from my Angular code:
this.httpClient.get('http://localhost/myjson.json').subscribe(data => {
datax.forEach(element => {
console.log(element.url);
});
The error message displayed:
error TS2339: Property 'forEach' does not exist on type 'Object'.
datay.forEach(element => {