-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
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.
Looks good to me! Look at comments with a few tips
console.log("Processing data:", data); | ||
} | ||
|
||
fetchDataAsync('https://jsonplaceholder.typicode.com/todos/1'); |
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.
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(); |
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.
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(); |
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.
The same here
No description provided.