Skip to content

London | 26-ITP-May | Martin Mwaka | Sprint 3 | Programmer humour - #546

Open
Temceo wants to merge 10 commits into
CodeYourFuture:mainfrom
Temceo:martin_programmer_humour
Open

London | 26-ITP-May | Martin Mwaka | Sprint 3 | Programmer humour#546
Temceo wants to merge 10 commits into
CodeYourFuture:mainfrom
Temceo:martin_programmer_humour

Conversation

@Temceo

@Temceo Temceo commented Aug 12, 2026

Copy link
Copy Markdown

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

Completed tasks for programmer humour

@Temceo Temceo 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. Module-Data-Flows The name of the module. labels Aug 12, 2026
@hey-hammad hey-hammad added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 21, 2026

@hey-hammad hey-hammad left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good structure overall, but the solution seems more complex than necessary for a single fetch-on-load scenario.

Comment thread fetch/programmer-humour/script.js Outdated
const imageElement = document.querySelector("img");
const endpoint = `https://xkcd.now.sh/?comic=latest`;

let imageCache = null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we expect fetchImageData() to be called multiple times during the page lifecycle? If not, could we simplify the implementation by removing the cache/promise management and fetching the data directly?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have simplified this to collect the data directly

Comment thread fetch/programmer-humour/script.js Outdated
let imageCache = null;
let imagePromise = null;

const state = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there a reason we're storing the response in a global state object? Since the data appears to be consumed immediately by renderImage(), could we pass it directly as a parameter instead of maintaining additional state?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I am now passing the data directly to renderImage

Comment thread fetch/programmer-humour/script.js Outdated
imgData: {},
};

async function fetchImageData() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I noticed that function is defined using async, but its using .then() inside. Would it make sense to use await inside fetchImageData() as well?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I am now only using await

@hey-hammad hey-hammad added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 21, 2026
@Temceo Temceo added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Data-Flows The name of the module. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 🏕 Priority Mandatory This work is expected 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants