-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
NW6| BakhatBegum | Module-JS3 | Feature/humor |Sprint-3 #300
base: main
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
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 work, Bakhat, your app works wonderfully! 🚀
I've left a few comments for you to check out, reach out on Slack if you have any questions.
Also be careful of your branches, to make sure that other exercises aren't accidentally included in the PR (I can see the book-library/
directory has come in to this PR).
} | ||
}); | ||
} | ||
getImageFetch(); |
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.
Because we call getImageFetch()
from inside the displayData()
function, we don't need to call it here 🙂
} | ||
const image = data.img; | ||
|
||
const createImage = document.createElement('img'); |
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 really like how you create the image element inside JavaScript! It means the user doesn't see a 'broken image' when they first load the page, creating a nice user experience
if(!data){ | ||
console.log("data can not found"); | ||
} | ||
const image = data.img; |
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.
Could this variable name be a bit more descriptive? For example, imageUrl
would make it clear that this is the link to the image
} | ||
displayData(); | ||
|
||
window.onload = displayData; |
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.
When I launch the page, I see the same image appear twice. Having a look at these final lines of the JavaScript file, can you think why that might be?
function getImageFetch(){ | ||
return fetch('https://xkcd.now.sh/?comic=latest').then((response) => { | ||
if(!response.ok){ | ||
return "Error"; |
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.
Instead of just returning the text "Error", we could instead throw an exception. This is a large topic to cover here, so reach out on Slack if you have any questions on what this means!
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.