Just wanted to know, how would I be able to iterate through my json Object in the following format?
[
{"page":1,"pages":1,"per_page":"600","total":264},
[
{
"indicator":
{"id":"NY.GDP.MKTP.CD","value":"GDP (current US$)"},
"country":{"id":"1A","value":"ArabWorld"},
"value":"2565871160292.11","decimal":"0","date":"2015"
},
{
"indicator":
{"id":"NY.GDP.MKTP.CD","value":"GDP (current US$)"},
"country":{"id":"S3","value":"Caribbean small states"},
"value":"66935278418.3676","decimal":"0","date":"2015"
},
{
"indicator":
{"id":"NY.GDP.MKTP.CD","value":"GDP (current US$)"},
"country":{"id":"B8","value":"Central Europe and the Baltics"},
"value":"1281495024762.4","decimal":"0","date":"2015"
}
]
]
I have this method which returns the json object
countries: function() {
const URL = 'http://api.worldbank.org/countries/all/indicators/NY.GDP.MKTP.CD?date=2015:2015&per_page=600&format=json'
let countries = []
fetch(URL).then(i => i.json()).then(j => countries.push(...j))
console.log(countries);
}
So for instance, how would I be able to select the date
field?
Thanks -B