Skip to content
  • Unlock Pro
  • Log in with GitHub
Profile
OverviewSolutions
4
Comments
1
Raymond
@IpieA

All comments

  • P
    Ornella T•425
    @ornel77
    Submitted about 2 years ago

    Code with React - Feedback are welcomed :)

    #react#fetch
    1
    Raymond•70
    @IpieA
    Posted about 2 years ago

    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

Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub