-
-
Save andyfleming/ab5baa85704f8e205996ab44795ef501 to your computer and use it in GitHub Desktop.
Promise Request Example
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 request = require('request-promise') | |
const microtime = require('microtime') | |
const API_BASE_URL = 'http://localhost:9200' | |
const start = microtime.now() | |
Promise.all([ | |
request(API_BASE_URL + '/one'), | |
request(API_BASE_URL + '/two'), | |
request(API_BASE_URL + '/three') | |
]).then((results) => { | |
console.log(results) | |
console.log('Completed in ' + Math.round((microtime.now() - start)/1000) + ' ms') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment