Skip to content

Instantly share code, notes, and snippets.

@CyberRoute
Created October 5, 2018 10:47
Show Gist options
  • Save CyberRoute/9912366b8ff140d0a1856a6089be1e39 to your computer and use it in GitHub Desktop.
Save CyberRoute/9912366b8ff140d0a1856a6089be1e39 to your computer and use it in GitHub Desktop.
challenge_js
var http = require('http');
function follow(url, cb) {
http.get(url, function(res) {
res.on('data', function (chunk) {
var data = JSON.parse(chunk.toString());
if (!data || !data.follow) {
cb(data);
return;
}
follow(data.follow.replace('challenge?', 'challenge.json?'), cb);
console.log(data.follow);
});
});
}
follow('http://letsrevolutionizetesting.com/challenge.json', function (data) {
if ( typeof data.follow !== 'undefined' && data.follow ){
console.log(data.follow);}
console.log(data.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment