JSFiddle - React, Tailwind, and code Playground
by jihyng_hd
JavaScript
$.getJSON("https://api.worldbank.org/v2/country/?format=json&per_page=500", function(data) {
obj = data[1];
console.log(obj);
newArray = [];
$.each(obj, function(i,v) {
if (v['incomeLevel']['value'] == "Aggregates" || v['incomeLevel']['value'] == "Low income") return;
item = {};
item['name'] = v['name'];
item['code3'] = v['id'];
item['code2'] = v['iso2Code'];
item['capital'] = v['capitalCity'];
item['region'] = v['region']['id'];
item['lat'] = v['latitude'];
item['lon'] = v['longitude'];
//item['incomeLevel'] = v['incomeLevel']['value'];
newArray.push(item);
})
//console.log(newArray);
console.log(JSON.stringify(newArray));
});