Design comparison
SolutionDesign
Solution retrospective
<h1>Hello all š¤</h1>
Advice Generator with Fetch API
Community feedback
- @dwhensonPosted almost 3 years ago
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 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