Last active
May 12, 2021 01:51
-
-
Save tiffboors29/a93c36f97a6c85b2c72298ebee89edbe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let http = require('http'); | |
(function follow(url){ | |
url = url.indexOf('?') !== -1 ? url.replace(/\?/,'.json?') : url + '.json'; | |
http.get(url, response => { | |
let rawData = ''; | |
response.on('data', data => { | |
rawData += data; | |
}); | |
response.on('end', data => { | |
let obj = JSON.parse(rawData); | |
if (obj['follow']){ | |
console.log(obj); | |
follow(obj['follow']); | |
} | |
else { | |
console.log(obj['message']); | |
} | |
}) | |
}) | |
}('http://letsrevolutionizetesting.com/challenge')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment