Async and Await
It has always been the dream of JavaScript developers to handle async functions without the need to write wrappers around them. Then, a new feature was introduced, and that changed everything we know about JavaScript async operations. Consider the code we used in the last exercise:
function getFullRecord(id) {
return getProfile(id)
.then(getCart)
.then(getSubscription);
}
It is simple enough because we used promise chaining, but it doesn't really tell us anything more than that, and it appears we are just calling a bunch of functions. What if we could have something like this:
function getFullRecord(id) {
const profile = getProfile(id);
const cart = getCart(id);
const subscription = getSubscription(id);
return {
...profile,
cart,
...