Skip to content

Instantly share code, notes, and snippets.

@selynna
Created February 21, 2016 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selynna/6e96154bb094bb26d660 to your computer and use it in GitHub Desktop.
Save selynna/6e96154bb094bb26d660 to your computer and use it in GitHub Desktop.
lolololol twilio
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