@debriks
Posted
Hi Adarsh,
You're clearly better than I am at Javacript but I noticed that you have the same problem I had on your Advice Generator App and I wanted to share with you the fix I found on stackoverflow, maybe you will find it useful.
In your app, you have to push twice the button to get a new advice, it takes a bit of delay. It is because of the cache (there's actually a note about it on the API website : Advice is cached for 2 seconds. Any repeat-request within 2 seconds will return the same piece of advice).
I fixed this small issue by simply adding { cache: "no-cache" }
to the API response like so:
const response = await fetch(END_POINT, { cache: "no-cache" });
Hope you will find this useful.
Happy coding!!
Marked as helpful