Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Promise map (Bluebird)
const Bluebird = require('bluebird')
const got = require('got')
const urls = [
// Bluebird is an extension of promises:
.map(url => got(url), {concurrency: 4})
.map(response => response.body)
.map((html, i) => {
// Now you can access/parse each response as `html` here, and reshape the value for the next `.then` or `.map`
return {html: html, url: urls[i]}
}, {concurrency: 8})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.