-
-
Save kypflug/20cfe09274331571b545f08f273d3e7d to your computer and use it in GitHub Desktop.
retrieve-JSON-via-fetch
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
fetch('weather.json') | |
.then(function(response) { | |
if (response.headers.get('content-type') == 'application/json') { | |
return response.json(); | |
} else { | |
throw new TypeError(); | |
} | |
}) | |
.then(processJSON); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment