Last active
April 3, 2019 09:24
-
-
Save gladchinda/36f46aadcf316e604ae67e1db43d0c5f 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 fetchTempForCity = city => { | |
return fetch(`${API_URL}&q=${encodeURIComponent(city)}`) | |
.then(response => response.json()) | |
.then(data => [ city, data.main.temp || null ]) | |
// Attach a `.catch()` handler for graceful rejection handling | |
.catch(() => [ city, null ]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment