Last active
November 15, 2018 13:39
-
-
Save jsrath/7ac76adab5799066c2ad6fb27d598d6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getData(event) { | |
event.target.value ? (country = event.target.value) : (country = countrySelect.selectedOptions[0].innerText); | |
for (let i = year; i < 2018; i++) { | |
let obj = {}; | |
await fetch(`http://api.population.io/ 1.0/population/${year}/${country}`) | |
.then(result => result.json()) | |
.then(result => result.map(age => age.total).reduce((a, b) => a + b)) | |
.then(result => { | |
obj['year'] = i; | |
obj['population'] = result; | |
}); | |
year++; | |
} | |
drawGraph(clientWidth); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment