I have a JSON response like this:
{
"AD": {
"name": "Andorra",
"native": "Andorra",
"phone": "376",
"continent": "EU",
"capital": "Andorra la Vella",
"currency": "EUR",
"languages": [
"ca"
]
},
"AE": {
"name": "United Arab Emirates",
"native": "دولة الإمارات العربية المتحدة",
"phone": "971",
"continent": "AS",
"capital": "Abu Dhabi",
"currency": "AED",
"languages": [
"ar"
]
},
And I want to iterate over the countries capitals, only. But as for now I can only get the key of the contry and i'm not being able to reach the nested properties. I'm using this code in my subscription:
subscribe(data=>{
let cityProps=Object.keys(data);
let cityList=[]
for(let prop in cityProps){
cityList.push(cityProps[prop]);
}
this.cities=cityList;
console.log(cityList)
I understand that this logic will only give me an array of "AD","AE" and so on. But how can I get the names?