Created
April 16, 2017 03:20
-
-
Save jibwa/e4b96eeac32f4dc287b979ada4ff1bd5 to your computer and use it in GitHub Desktop.
Bluebird es6 elegant async promise with data response 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
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