Created
December 11, 2017 22:39
-
-
Save ernestofreyreg/2f0724e7099cf2a25b67a9519c1ce7fd 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 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