Last active
April 2, 2019 18:06
-
-
Save gladchinda/99973de7e28e7f8e7a9d87edecebf4e1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const exchangeRate = currency => { | |
const symbol = `${BASE_CURRENCY}_${currency}`; | |
return fetch(`${API_URL}&q=${symbol}`) | |
.then(response => response.json()) | |
.then(data => [ currency, data[symbol] || null ]) | |
// Attach a `.catch()` handler for graceful rejection handling | |
.catch(() => [ currency, null ]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment