Design comparison
Solution retrospective
Question:
- My dice button functionality does not work completely properly. While it renders a new advice, this happens only after a few clicks. I'm not sure why it does not work on every single click
Any help would be greatly appreciated!
Community feedback
- @TheDilpPosted over 2 years ago
For the dice not fetching on each click, if you're using the fetch API set the cache to "no-store" or "no-cache", example on MDN Docs.
You can see the issue in the network tab of the DevTools of your browser, it is fetching on each click, but from the cache, meaning it gets the same advice. If you wait a second or two between each click then it will fetch new ones with the current settings.
Otherwise, great work! That's pretty close to the design 👍
Marked as helpful1@KarolisGaivPosted over 2 years ago@TheDilp Oh wow! :O It works! Thanks a lot for this advice.
Just out of curiosity - how common is this solution to set cache parameters in fetch API?
1@TheDilpPosted over 2 years ago@KarolisGaiv No worries.
I don't know, it was the solution that first came to my mind when I encountered the same problem, I'm sure there are other ways to tackle it (as with all things in programming).
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