Skip to content

London | 26-ITP-January | Eugenie Ahangama | Sprint 3 | Programmer Humor#398

Open
Eugenie-A wants to merge 3 commits intoCodeYourFuture:mainfrom
Eugenie-A:feature/xkcd
Open

London | 26-ITP-January | Eugenie Ahangama | Sprint 3 | Programmer Humor#398
Eugenie-A wants to merge 3 commits intoCodeYourFuture:mainfrom
Eugenie-A:feature/xkcd

Conversation

@Eugenie-A
Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

  • Created HTML, CSS and JavaScript files
  • Fetches JSON using fetch
  • Function makes API call to the correct endpoint
  • Logs received data to the console
  • Renders the img property into an <img> tag in the DOM
  • Error handling with try/catch

Questions

Is there a better way to handle errors than just console.log(error) - should I be displaying something to the user instead?

@Eugenie-A Eugenie-A added 🏕 Priority Mandatory This work is expected 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Submit:PR Module-Data-Flows The name of the module. Core This is a core task and should be completed by all trainees labels Apr 4, 2026
@Luro91 Luro91 added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Apr 11, 2026
Copy link
Copy Markdown

@Luro91 Luro91 left a comment

Choose a reason for hiding this comment

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

Well done. This is a nice implementation and you used meaningful commit messages that make it easy to understand what each commit does.

Regarding your question:

Is there a better way to handle errors than just console.log(error) - should I be displaying something to the user instead?

In general it's good practice in terms of UX to give the user feedback if an error occurs. This can be done by showing an error message. (As an advanced topic you could also show a loader animation while the data is being fetched)

Comment on lines +5 to +14
// Convert the response to JSON
const data = await response.json();
// Log the data to the console
console.log(data);

// Grab the comic container from the DOM
let comicDiv = document.getElementById("comic");
// Create an img element
let imgComic = document.createElement("img");
// Set the src of the img to the comic image URL
Copy link
Copy Markdown

@Luro91 Luro91 Apr 11, 2026

Choose a reason for hiding this comment

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

I understand that comments can help you writing the code. It is best practice to only place comments where they are needed for understanding. The code should be self explanatory and comments should mainly explain why things are written in a specific way.

From https://mitcommlab.mit.edu/broad/commkit/coding-and-comment-style/

The most important concept here is that the code itself is the primary means of commenting and documentation.
Use comments only to add context or explain choices that cannot be expressed through thoughtful naming, structure or the context of operations.

You could write the comments during the development and then remove them before committing it. Try to use less of them over time

@Luro91 Luro91 added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Core This is a core task and should be completed by all trainees Module-Data-Flows The name of the module. 🏕 Priority Mandatory This work is expected 📅 Sprint 3 Assigned during Sprint 3 of this module Submit:PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants