Skip to content

Instantly share code, notes, and snippets.

@tfogo
Last active January 23, 2017 20:50
Show Gist options
  • Select an option

  • Save tfogo/61b722da13cf6c741ec482b4e5b22715 to your computer and use it in GitHub Desktop.

Select an option

Save tfogo/61b722da13cf6c741ec482b4e5b22715 to your computer and use it in GitHub Desktop.
Making several requests to the Twilio API
// An array to hold all the promises we get from Twilio API requests
let promises = [];
for (let i = 0; i < 20; i++) {
// Make a call to the available phone numbers API for the US
let twilioPromise = client.availablePhoneNumbers('US').local.list({
areaCode: '650'
});
promises.push(twilioPromise);
}
// phonePromise will resolve when all of the promises in the promises array resolve
let phonePromise = Promise.all(promises);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment