Responsive, Flexbox

Solution retrospective
First time using API
Please log in to post a comment
Log in with GitHubCommunity feedback
- P@dwhenson
Hey @titocs,
Lovely job here. The app works well 🙌
One thing I would suggest in your JS is to add a check to ensure the API has responded correctly, and render an error message if not. This isn't too tricky, and I would just change the first
then
to be something like:.then(response => response.ok ? response.json() : throw new Error("API Failed")
Your current
catch
would work in the case of some failures, but checking theok
property on the response object is more robust. I would suggest you include some fallback text inside your that would render in case of any error. Something like:adviceTag.innerHTML = `Sorry! That didn't work!`; adviceQuote.innerHTML = `Please try again later and hopefully it'll be fixed.`;
Cheers 👋
Dave
Join 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