You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What specific section or headline is this issue about?
"This may be worse if you have race conditions"
What information was incorrect, unhelpful, or incomplete?
When I looked at the JS code:
const listOfIngredients = [];
doSomething()
.then((url) => {
// I forgot to return this
fetch(url)
.then((res) => res.json())
.then((data) => {
listOfIngredients.push(data);
});
})
.then(() => {
console.log(listOfIngredients);
// Always [], because the fetch request hasn't completed yet.
});
I could not really understand where the error was? Where should have been a return? Again, a simple good example would have been useful, one that particularly explains or points out where the return should have been in this bad example?
Further, I noticed, the "good" example was beneath the bad one, however, I could not see the difference! I had to copy paste the code in two notepads one by the other to NOTICE (after a minute or so) the actual difference was very subtle when reading... there was a { ... } bracket in the bad one, that was missing in the good one, etc.
What did you expect to see?
Please see the above section "What information was incorrect, unhelpful, or incomplete?"
Do you have any supporting links, references, or citations?
Adding an indication of where the return statement should have been in the bad example would clarify this a bit more. I can work on this.
I appreciate your willingness to work on this issue, @collinsnji! I will assign this issue to you. If you would no longer like to work on this issue, or we don't hear from you in a few days, I'll open the issue back up to the community.
Edit: I see you've opened #29746 to resolve this issue. Thanks!!
MDN URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises
What specific section or headline is this issue about?
"This may be worse if you have race conditions"
What information was incorrect, unhelpful, or incomplete?
When I looked at the JS code:
I could not really understand where the error was? Where should have been a return? Again, a simple good example would have been useful, one that particularly explains or points out where the return should have been in this bad example?
Further, I noticed, the "good" example was beneath the bad one, however, I could not see the difference! I had to copy paste the code in two notepads one by the other to NOTICE (after a minute or so) the actual difference was very subtle when reading... there was a { ... } bracket in the bad one, that was missing in the good one, etc.
What did you expect to see?
Please see the above section "What information was incorrect, unhelpful, or incomplete?"
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
MDN metadata
Page report details
en-us/web/javascript/guide/using_promises
The text was updated successfully, but these errors were encountered: