Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Advice Generator Fetch API

P
Waldemar Glazā€¢ 775

@waldekglaz

Desktop design screenshot for the Advice generator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
  • API
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


<h1>Hello all šŸ¤Ÿ</h1>

Advice Generator with Fetch API

Community feedback

P
Daveā€¢ 5,245

@dwhenson

Posted

Hello, Waldemar! Lovely job here. The app works very nicely šŸ™Œ !!

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")

If you then add a catch at the end of of your fetch function you can render some fallback text in case things don't work for any reason. It's not a big deal, but thinking about how things can go wrong is a good habit to get into.

Cheers šŸ‘‹

Dave

1

Please log in to post a comment

Log in with GitHub
Discord logo

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