Advice generator app with React and Fetch API

Solution retrospective
I am mostly proud of adding a loading to state to the application. Whenever the user generates a new advice, the previous advice text changes to a text saying 'generating advice'. Also adding a simple error state to display in case the app cannot generate a new one.
What challenges did you encounter, and how did you overcome them?During development I found that reloading the page or generating a new advice using the fetch api, it didn't actually generated a new one (in Firefox). Thought it was the API, but it only cached the request for 2 seconds. I had to add fetch method an init object with a property of cache: "no-store", so it actually fetched a new advice.
Apart from the issue with fetching a new advice in Firefox. I had none. But if there is a better way to handle it, I'm all open ears.
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on Alvaro Másmela’s solution.
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