Created
November 14, 2014 20:02
-
-
Save cadebward/b9352cdc46de7970ad56 to your computer and use it in GitHub Desktop.
rainforest-challenge.js
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
var url = require('url'); | |
var request = require('request'); | |
var options = { | |
url: 'http://letsrevolutionizetesting.com/challenge', | |
headers: { | |
'Accept': 'application/json' | |
} | |
}; | |
function callback(error, response, body) { | |
if (!error && response.statusCode == 200) { | |
var respJSON = JSON.parse(body); | |
console.log(respJSON) | |
if (!respJSON.follow) { | |
return | |
} | |
var parsedUrl = url.parse(respJSON.follow); | |
var search = parsedUrl.search; | |
follow(search); | |
} | |
} | |
function follow(search) { | |
var obj = { | |
url: 'http://letsrevolutionizetesting.com/challenge' + search, | |
headers: { | |
'Accept': 'application/json' | |
} | |
}; | |
request(obj, callback); | |
} | |
request(options, callback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment