Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Zetouny
Copy link

@Zetouny Zetouny commented Apr 14, 2025

No description provided.

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
@durw4rd durw4rd self-assigned this Apr 29, 2025
Copy link

@durw4rd durw4rd left a 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');
Copy link

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) => {
Copy link

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(
Copy link

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.

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