Last active
December 9, 2018 21:17
-
-
Save jsrath/ccbadc4aa0c4c9870e570969f1150c38 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 getCurrencies(url) { | |
await fetch(url) | |
.then(result => result.json()) | |
.then(result => sortCurrencies(result)) | |
.then(result => setOptions(result)); | |
} | |
function sortCurrencies(data) { | |
const base = [data.base]; | |
const currencies = Object.keys(data.rates); | |
setDefaultDate(data.date); | |
return base.concat(currencies).sort((first, second) => first.localeCompare(second)); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment