Advice Generator App

Please log in to post a comment
Log in with GitHubCommunity feedback
- @aliadelharrat
Hello and congratulations on completing this challenge! 🎉
Great job on creating a UI that is pretty identical. It seems you have encountered a small bug where clicking on the dice button does not fetch new advice. This issue is due to the server and not your code.
To fix this problem, you can modify the API fetch request. Instead of using:
// Fetching the random advice data fetch("https://api.adviceslip.com/advice")
You can use the following code:
// Fetching the random advice data fetch(`https://api.adviceslip.com/advice?t=${Math.random()}`)
By appending
?t=${Math.random()}
to the API URL, you add a random query parameter, which helps bypass any caching mechanisms on the server side. This ensures that each request is treated as unique, and you receive new advice every time you click the dice button.I hope this helps! Let me know if you have any further questions. 👋
Marked as helpful
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