Created
September 15, 2022 00:07
-
-
Save james-zedd/50ea88e9da0c97a6a9b37d252ce45ebc to your computer and use it in GitHub Desktop.
You should try json
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 axios = require('axios').default; | |
const URL = 'https://letsrevolutionizetesting.com/challenge.json'; | |
function call(url) { | |
return axios.get(url).then((res) => { | |
return res.data; | |
}); | |
} | |
function start(url) { | |
return call(url).then((res) => { | |
const { follow } = res; | |
if (follow) { | |
return start(follow.replace('challenge?', 'challenge.json?')); | |
} | |
return res; | |
}); | |
} | |
start(URL) | |
.then(({ message }) => console.log(`Result: ${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