I'm working with an api json to load a list of countries, then a list of states then a list of the cities of that state and country. Thing is, I'm strugling with the second call I make in the api. First I load a list of continents. Then I go for the 'lists' of the countries. Problem is since I have to loop on the continents in order to get the countries, I have to concatenate or add the multiple lists as one. And I don't know how to do it. Here is my code so far:
pegPaises2(): void {
let count = 0;
console.log('nóis na fita');
this.httpp.get('http://www.geonames.org/childrenJSON?geonameId=6295630')
.subscribe((resContinents: Response) => {
resContinents.json().geonames.forEach(element => {
this.httpp.get(`http://www.geonames.org/childrenJSON?geonameId=${element.geonameId}`)
.subscribe((resCountries: Response) => {
resCountries.json().geonames.forEach(elementt => {
count = count + 1;
const Country = new COUNTRY;
Country.geonameId = elementt.geonameId;
Country.name = elementt.name;
console.log(count, Country);
// console.log(count, elementt.geonameId, elementt.name);
});
});
});
});
// return ;
}
I think I could have an observable or an array. But tried using push and didn't find any example that I could understand(beginner here).