Created
April 16, 2017 03:17
-
-
Save jibwa/6eb68778a22957fa9dbbb87b9cd2a4e3 to your computer and use it in GitHub Desktop.
Plain es6 promise solution to async with followup and collecting args for response
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
Promise.all([ | |
Product.create({ | |
name: 'MacbookPro', | |
qty: 1232213, | |
price: 10000. | |
}), | |
Order.findOne({ | |
orderNumber: 123 | |
}) | |
]) | |
.then(([product, order]) => | |
ProductOrder.create({ | |
product: product.id, | |
order: order.id | |
}) | |
.then(productOrder => res.ok(product, order, productOrder)) | |
) | |
.catch(res.negotiate); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment