-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Challenge - Gabriel Echeverria #27
base: master
Are you sure you want to change the base?
Conversation
return firstNameFetcher(lastName); | ||
}) | ||
.then(firstName => { | ||
console.log(`Finished fetching name: ${firstName}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to print the fullname, instead of firstname and lastname separated, refactor to do it possible for this solution
3-async-await/solution.js
Outdated
const requests = Promise.all([fetchProducts(id), fetchPrices(id)]); | ||
|
||
try { | ||
const [product, price] = await requests; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [product, price] = await requests; | |
const [product, price] = await Promise.all([fetchProducts(id), fetchPrices(id)]); |
3-async-await/solution.js
Outdated
|
||
// Log the results, or errors, here | ||
const results = await requestsSettled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const results = await requestsSettled; | |
const results = await Promise.allSettled([fetchPrices(id), fetchProducts(id)]); |
3-async-await/solution.js
Outdated
const settledObject = new Object(); | ||
settledObject.id = id; | ||
|
||
results.forEach((result, index) => { | ||
if (result.status === 'fulfilled') { | ||
settledObject[keyName(index)] = result.value; | ||
} else if (result.status === 'rejected') { | ||
console.log(`Ecountered allSettled error: ${result.reason}`); | ||
} | ||
}); | ||
|
||
console.log('Promise.allSettled() fetched:'); | ||
console.log(settledObject); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const settledObject = new Object(); | |
settledObject.id = id; | |
results.forEach((result, index) => { | |
if (result.status === 'fulfilled') { | |
settledObject[keyName(index)] = result.value; | |
} else if (result.status === 'rejected') { | |
console.log(`Ecountered allSettled error: ${result.reason}`); | |
} | |
}); | |
console.log('Promise.allSettled() fetched:'); | |
console.log(settledObject); | |
let settledObject = { id }; | |
results.forEach((result, index) => { | |
if (result.status === 'fulfilled') { | |
settledObject = { ...settledObject, [keyName(index)]: result.value }; | |
} else if (result.status === 'rejected') { | |
console.log(`Ecountered allSettled error: ${result.reason}`); | |
} | |
}); | |
console.log('Promise.allSettled() fetched:'); | |
console.log(settledObject); |
what about Promise.any, Promise.race and using args? |
No description provided.