-
Notifications
You must be signed in to change notification settings - Fork 10
Ahmad_Zetouny-w2-UsignAPIs #43
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
base: main
Are you sure you want to change the base?
Ahmad_Zetouny-w2-UsignAPIs #43
Conversation
new file: .test-summary/TEST_SUMMARY.md new file: .vscode/launch.json new file: 3-UsingAPIs/Week2/test-reports/ex1-programmerFun.report.txt new file: 3-UsingAPIs/Week2/test-reports/ex2-pokemonApp.report.txt new file: 3-UsingAPIs/Week2/test-reports/ex3-rollAnAce.report.txt new file: 3-UsingAPIs/Week2/test-reports/ex4-diceRace.report.txt new file: 3-UsingAPIs/Week2/test-reports/ex5-vscDebug.report.txt new file: 3-UsingAPIs/Week2/test-reports/ex6-browserDebug.report.txt
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.
Good job Ahmad, thanks for your work!
async function fetchData(url) { | ||
const getData = await fetch(url); | ||
if (!getData.ok) { | ||
throw new Error('Invalid URL'); |
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.
There could also be other errors - for example, the API endpoint could be unresponsive. A better handling of the error would be logging the details of the response
object.
document.body.appendChild(selector); | ||
} | ||
|
||
pokemonList.map((pokemon) => { |
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.
Nice use of the map
method.
Just FYI, most other students would use the forEach
method here.
|
||
selector.addEventListener('change', async () => { | ||
try { | ||
const data = await fetchData( |
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.
I would prefer if fetching the Pokémon image was handled within the fetchImage
function.
No description provided.