I’m doing the random quote machine chalenge using https://quotesondesign.com/api-v4-0/ I was getting the code on the page, then it stopped working and on the console i get this error:
But anyway, when I load this into codepen (because it’s quicker), and it works fine.
But when I load it locally on my system, it doesn’t, same problem as you.
I have a quote API test program that has the same issue. It crashes for CORS problems for quotesondesign (but for some reason has no problem with forismatic.
CORS problems are always a pain in the butt. I would recommend doing some research there. I did some searching and found that Chrome doesn’t like dealing with CORS from localhost. So I tried Firefox, but same problem. So I tried IE and it worked.
I think that the problem here is because it is being locally served. Certain browsers have an issue with that. When you put this on the internet, it won’t be a problem. For now, You can use IE to test it locally. There are also ways to turn off the CORS protection in the other browsers, but that is too complicated for now.
The other issue is that your code, when it works, is “returning” the same quote every time - you need to prevent the browser from caching in the code.
This. The only thing I have to add is that if you are accessing it with, ie; localhost:3000, you might try 127.0.0.1:3000 instead. I think sometimes it makes a difference.
I use a mac so I cant install IE, is it there any other browser I can test this? I already tried on Safari and Firefox and on Codepen I continue to get the same error.