Skip to content

Instantly share code, notes, and snippets.

@kypflug

kypflug/sw-1.js Secret

Created December 15, 2017 01:53
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 kypflug/20cfe09274331571b545f08f273d3e7d to your computer and use it in GitHub Desktop.
Save kypflug/20cfe09274331571b545f08f273d3e7d to your computer and use it in GitHub Desktop.
retrieve-JSON-via-fetch
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