Skip to content

Instantly share code, notes, and snippets.

@jibwa
Created April 16, 2017 03:20
Show Gist options
  • Save jibwa/e4b96eeac32f4dc287b979ada4ff1bd5 to your computer and use it in GitHub Desktop.
Save jibwa/e4b96eeac32f4dc287b979ada4ff1bd5 to your computer and use it in GitHub Desktop.
Bluebird es6 elegant async promise with data response example
import Promise from 'Bluebird';
Promise.join(
Product.create({
name: 'MacbookPro',
qty: 1232213,
price: 10000.
}),
Order.findOne({
orderNumber: 123
})
)
.then((product, order) =>
Promise.join(
product,
order,
ProductOrder.create({
product: product.id,
order: order.id
})
)
)
.then(res.ok)
.catch(res.negotiate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment