Skip to content

Instantly share code, notes, and snippets.

@james-zedd
Created September 15, 2022 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save james-zedd/50ea88e9da0c97a6a9b37d252ce45ebc to your computer and use it in GitHub Desktop.
Save james-zedd/50ea88e9da0c97a6a9b37d252ce45ebc to your computer and use it in GitHub Desktop.
You should try json
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