Created
May 15, 2018 11:38
-
-
Save siarhei-zharnasek/5221b5f0e5ccb2ed76db2a1b67b2d3ff to your computer and use it in GitHub Desktop.
This file contains 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