Advice generator with Fetch, CSS flex, css animation
Design comparison
Solution retrospective
I have added a little animation to the dice button. The only problem I have encountered is that when button is clicked twice too fast, fetch returns the same response. I am new to this and I am wondering if there is a way to improve this.
Community feedback
- @msunjiPosted over 2 years ago
Heya Jan!
The animation effect you've added is super neat. Well done! 👍
The reason why you're receiving the same response is likely because of the Advice Slip JSON API itself. From the docs: "Note: Advice is cached for 2 seconds. Any repeat-request within 2 seconds will return the same piece of advice."
What you can do instead is try adding
{ cache: 'no-store' }
to your fetch request. I've seen this as a suggested solution as well. Hope this helps!Marked as helpful0@JanWu100Posted over 2 years ago@msunji Thanks a lot :) I think I need to start reading those docs ;) I will read up on this. Thanks!
0
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