-
-
Save jakearchibald/8a9c47094b6e31de5cb2 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
function assertOkResponse(response) { | |
if (response.type === 'opaque' || response.status === 200) { | |
return response; | |
} | |
throw Error("Bad response: " + response.status); | |
} | |
fetch(url, {'mode': 'cors'}).then(assertOkResponse).then(function(response) { | |
// cache | |
}).catch(function(err) { | |
console.error('Fetch Error :-S', err); | |
throw err; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment