Skip to content

Instantly share code, notes, and snippets.

@jsrath
Last active December 9, 2018 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsrath/ccbadc4aa0c4c9870e570969f1150c38 to your computer and use it in GitHub Desktop.
Save jsrath/ccbadc4aa0c4c9870e570969f1150c38 to your computer and use it in GitHub Desktop.
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