I'm trying to use World Bank's API to obtain some data. This is how to query their database. Basically to query a country's information, I would need to go to this url:
http://api.worldbank.org/countries/"alpha2Code of the country"
In my code here (Link to CodePen code.) I use use the alpha2Code from a previous query to add to the World Bank query's URL. Here's the method:
getDetails(alpha2Code) {
this.load('http://api.worldbank.org/countries/'+alpha2Code)
.then((countryDetails) => {
this.generateOverlay(countryDetails);
});
},
the load() method is defined here:
load(url, type = 'json') {
return $.ajax({
dataType: type,
url: url,
});
},
According to World Bank's basic calling format, I would need to add
format=json
in order to receive response in JSON. Somehow I don't think it's actually obtaining anything from WorldBank.
The query to World Bank is suppose to give me details to put into the overlay that covers the country flags after a click.
Thank you in advance for the help!
generateOverlayis even being called? Have you verified in the browser debugger tools that the response is coming back with the data you're expecting?