Last active
March 29, 2017 07:21
-
-
Save davidgf/03ad5c6364695ffd3cf626afad9bf938 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
const makeRequest = () => { | |
return getJSON() | |
.then(data => handleResult(data)) | |
} | |
const handleResult = (data) => { | |
return data.needsAnotherRequest | |
? handleIncompleteResult(data) | |
: handleCompleteResult(data); | |
} | |
const handleIncompleteResult = (data) => { | |
return makeAnotherRequest(data) | |
.then(moreData => { | |
console.log(moreData) | |
return moreData | |
}); | |
} | |
const handleCompleteResult = (data) => { | |
console.log(data) | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment