-
Notifications
You must be signed in to change notification settings - Fork 17
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
Lidya-w2-usingAPIs #63
base: main
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.
Great job Lidya. I left you some comments and tips on code improvements but they are not a blocker for me. I would have requested changes for ex2 to be fixed before an approval usually if this was a real production code used by real users ;) Best of luck on the next modules.
return data; | ||
} catch (error) { | ||
console.error('Error fetching data:', error.message); | ||
displayError(error.message); |
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.
great job on displaying an error message to the user.
I didn't run this code locally but I can see that you might end up displaying the message twice to the user. Because I see you are throwing the error and in lines 56-58 you are catching it again and calling displayError again.
We should try to decouple the functions of fetching data from rendering to the UI. You can keep this function as generic as possible without even a try/catch. And since you already have a try/catch in the functions calling this e.g. fetchAndPopulatePokemons
and fetchImage
they will handle catching any errors and handing the UI display.
Great job though.
} | ||
|
||
// ! Do not change or remove the code below | ||
if (process.env.NODE_ENV !== 'test') { | ||
main(); | ||
} | ||
|
||
// TODO Replace this comment by your explanation that was asked for in the assignment description. | ||
/* When Promise.race() resolves, the first die to finish rolling determines the final result, the remaining dice continue rolling in the background because JavaScript promises | ||
cannot be cancelled once started. They will eventually resolve, but their results are ignored.*/ |
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.
👌
No description provided.