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 with Fetch, CSS flex, css animation

@JanWu100

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


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

P
Marge C. 440

@msunji

Posted

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 helpful

0

@JanWu100

Posted

@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 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