-
-
Save jdmedeiros/7f7116399ba72fa80e5b27d086e0d034 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 URL = 'https://letsrevolutionizetesting.com/challenge.json'; | |
function makeCall(url) { | |
return fetch(url).then(response => response.json()); | |
} | |
function startChallenge(url) { | |
return makeCall(url) | |
.then(response => { | |
const {follow} = response; | |
if (follow) { | |
return startChallenge(follow.replace('challenge?', 'challenge.json?')); | |
} | |
return response; | |
}); | |
} | |
startChallenge(URL) | |
.then(({message}) => console.log(`Result is: ${message}`)) | |
.catch(error => console.log(`Error: ${error}`)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment