I am stucked at using Api on codepen.io

I am stucked at using Api on codepen.io
0

#1

Hi everyone, I’m currently stuck at the Quote machine api project. I keep on getting this response in the web console.
“Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).”

this is the link to the codepen pen https://codepen.io/samimath/pen/baYXBP


#2

You can either prefix the forismatic.com url with a proxy such as https://cors-anywhere.herokuapp.com/ or you will need to use the $.ajax function and use JSONP for the dataType. The $.ajax documentation gives an example of this.


#3

Thank you sooooooooooooooooooooooooooooooooooooooooooooooo much, I’ve been able to solve the problem with the cors-anywhere prefix. I’m really greatful :sunglasses: