boba-milktea / advice-generator

0 stars 0 forks source link

firefox problem source #1

Closed anas-cd closed 2 years ago

anas-cd commented 2 years ago

Hi, just saw your solution at Frontend mentor and I had the exact same problem where it worked on Chrome but not Firefox, the problem turned out to be about caching in Firefox, the API URL recognizes the Firefox cache won't' allow for another request but after a very long time.

so basically disable caching in firefox, this will also allow you to bypass the one request per minute limit, not quite sure how to do it on Axios, I used Jquery for it but the point should be the same. you can check my repo for the same challenge as well.

happy coding, would love to know if it worked.

boba-milktea commented 2 years ago

Hi @anas-cd

It works! :thumbsup: Thank you so much for your response. And sorry for the late reply. I was knee-deep in another challenge. It's just brilliant how you found the root cause of the problem. Another workaround provided by @elaineleung is to add a random number (id) to the request. It copes well with the problem too.

happy coding! :muscle:

elaineleung commented 2 years ago

Thanks for the ping @boba-milktea! 🙂 Yes, I eventually saw someone use a cache object as a solution and I tried it out, works like a charm. I also thought of you but figured that maybe you might have moved on already 😆

If you haven't tried it yet, the solution just involves adding an object in fetch as the second argument, like this:

fetch("https://api.adviceslip.com/advice", { cache: 'no-cache' })

boba-milktea commented 2 years ago

Oh, that's pretty cool! @elaineleung
I will definitely try it! Thanks a bunch :grin:

anas-cd commented 2 years ago

glad to hear it. :smiley: :+1: