Skip to content

Instantly share code, notes, and snippets.

@ernestofreyreg
Created December 11, 2017 22:39
Show Gist options
  • Save ernestofreyreg/2f0724e7099cf2a25b67a9519c1ce7fd to your computer and use it in GitHub Desktop.
Save ernestofreyreg/2f0724e7099cf2a25b67a9519c1ce7fd to your computer and use it in GitHub Desktop.
function extractResponse (response) {
if (response.status === 200) {
return response.data
}
return []
}
function processError (err) {
logger.error(err)
return []
}
function dispatchData (dispatch) {
return data => dispatch(data)
}
function someAsyncFunction (dispatch) {
return axios.get('/api/endpoint')
.then(extractResponse, processError)
.then(dispatchData(dispatch))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment