Created
February 21, 2016 04:36
-
-
Save selynna/6e96154bb094bb26d660 to your computer and use it in GitHub Desktop.
lolololol twilio
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
const async = require('async'); | |
const request = require('request'); | |
async.waterfall([(callback) => { | |
request.post({ | |
url: 'https://mhacks-hunt-spring-2016.herokuapp.com/hotel', | |
form: { | |
token: 'KzE2NTAzOTAzNzA5' | |
} | |
}, (err, http_response, body) => { | |
var json = JSON.parse(body); | |
callback(null, json.token); | |
}); | |
}, (token, callback) => { | |
request.get(`https://mhacks-hunt-spring-2016.herokuapp.com/icicle?token=${token}`, (err, http_response, body) => { | |
console.log(body); | |
var json = JSON.parse(body); | |
callback(null, json.token, json.remaining); | |
}); | |
}, (token, times, callback) => { | |
async.whilst(() => times > 0, (callback) => { | |
request.get(`https://mhacks-hunt-spring-2016.herokuapp.com/jello?token=${token}`, (err, http_response, body) => { | |
console.log(body); | |
times--; | |
token = JSON.parse(body).token; | |
callback(); | |
}); | |
}, callback); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment