Skip to content
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

Lesson 6 JS Async Await #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Lesson 6 JS Async Await #5

wants to merge 4 commits into from

Conversation

DenisKozachok
Copy link
Owner

No description provided.

Copy link

@nzamishchak nzamishchak left a comment

Choose a reason for hiding this comment

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

Looks good to me! Look at comments with a few tips

console.log("Processing data:", data);
}

fetchDataAsync('https://jsonplaceholder.typicode.com/todos/1');

Choose a reason for hiding this comment

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

To call async function it is better to use anonymous function
(async () => { await fetchDataAsync('https://jsonplaceholder.typicode.com/todos/1'); })();

if (!response.ok) {
throw new Error(`Primary request failed with status: ${response.status}`);
}
return await response.json();

Choose a reason for hiding this comment

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

Here await is redundant as the returned json is already Promise

if (!fallbackResponse.ok) {
throw new Error(`Fallback request failed with status: ${fallbackResponse.status}`);
}
return await fallbackResponse.json();

Choose a reason for hiding this comment

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

The same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants