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

Code with React - Feedback are welcomed :)

Ornella T 425

@ornel77

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


Hello, I have a bug when I click quickly, the advice doesn't update right away. If you have a solution please tell me :)

Thank you,

Ornella

Community feedback

Raymond 70

@IpieA

Posted

Hey Ornella, great work. I just worked on this too.

So, the API documentation says "Advice is cached for 2 seconds. Any repeat-request within 2 seconds will return the same piece of advice." That's probably why quick clicks won't update immediately, but after 2 seconds

To get past this, you can generate a random query parameter and append to the API URL to bypass the caching mechanism. This is what I mean:

const timestamp = Date.now(); const res = await fetch(https://api.adviceslip.com/advice?timestamp=${timestamp});

It tricks the API server to think that it is a new request each time. I hope this helps

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