Responsive Recommendations Application with CSS Grid.
Design comparison
Solution retrospective
I'm proud of having completed the challenge in record time for me. Next time, I would take a bit more time to improve and refine certain details.
What challenges did you encounter, and how did you overcome them?- Challenges: Guessing the
font-size
,font-weight
, color, and the card's width. - Solution: I defined common measurements for font size and weight. For the color, I used a color picker tool to match it as closely as possible.
I would like help with JavaScript. I know how to make an API request, but I need to learn how to do it following best practices and with better code structure.
Community feedback
- @ShivangamSoniPosted 10 days ago
The
adviceData
that you have created for initialization is not needed at all. Since you are making a request onDOMContentLoaded
there's no need for an initial dummy data. Also, the initial loading UI is being shown because that's the default you have written in your markup. You can simply pass the response data to theupdateUI
function.Another thing is the way you are handling the error, you don't have to update the UI manually to show the error you can simply reuse your
updateUI
function to display errors.async function getAdvice() { try { const response = await fetch("https://api.adviceslip.com/advice"); const data = await response.json(); updateUI(data.slip); } catch (error) { console.error("Failed to fetch advice:", error); updateUI({id: "404", advice: "An error occurred. Please try again."}); } }
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord