I am new to Angular10 and I am trying to loop through a JSON object but can't work it out.
My JSON object:
[
{
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"
}
]
Part of my Angular script:
this.httpClient.get('http://localhost/myjson.json').subscribe(data => {
datax.forEach(element => {
console.log(element.url);
});
The error
error TS2339: Property 'forEach' does not exist on type 'Object'.
datay.forEach(element => {
dataafter you subscribe? I think it might be an object withresponseproperty..jsonfile if you enter that URL in browser?