Skip to content

Instantly share code, notes, and snippets.

@andyfleming
Last active January 20, 2017 03:41
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 andyfleming/ab5baa85704f8e205996ab44795ef501 to your computer and use it in GitHub Desktop.
Save andyfleming/ab5baa85704f8e205996ab44795ef501 to your computer and use it in GitHub Desktop.
Promise Request Example
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