Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JonathanMatthey/98597fb6d7a733b4236171bce6408e42 to your computer and use it in GitHub Desktop.
Save JonathanMatthey/98597fb6d7a733b4236171bce6408e42 to your computer and use it in GitHub Desktop.
rainforestQA-follow function
var getJSON = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
function follow(data){
console.log(data);
if(data.follow)
getJSON(data.follow.replace('challenge','challenge.json'), function(status,data){follow(data)})
}
follow({follow:"https://www.letsrevolutionizetesting.com/challenge"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment