Skip to content

Instantly share code, notes, and snippets.

Last active December 23, 2018 07:05
What would you like to do?
const isOk = response => response.ok ? response.json() : Promise.reject(new Error('Failed to load data from server'))
.then(isOk) // <= Use `isOk` function here
.then(data => {
console.log(data) // Prints result from `response.json()`
.catch(error => console.error(error))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment