Last active
January 23, 2017 20:50
-
-
Save tfogo/61b722da13cf6c741ec482b4e5b22715 to your computer and use it in GitHub Desktop.
Making several requests to the Twilio API
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
| // 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