Not able access Content of API response

I am trying to hit the API and get the content from Response but not able to do it with my code. PLease check my code and explain me.

$(".btn-primary").on(“click”,function(){
$.ajax({
type:“GET”,
datatype:JSON,
url:“https://quotesondesign.com/wp-json/posts?filter[orderby]=rand”,
success:function(data){
/* var post = data.shift(); */
$("#quote").html(data.content);
}

});

});

having the link to codepen if it is one there would help…im not 100% but i think dataType should be a string…have you tried devtools yet?

This is codepen Link:https://codepen.io/sriramdvhere/pen/GEQzrE.I dont know how to use Dev Tool for this. Pls Help

@sriramdvhere you were close i forked and fixed…the data was in an array so you had to do data[0].content there you go!! https://codepen.io/benjaminadk/pen/OgEMXG?editors=0010

if you use chrome browser shift+control+i opens dev tools you should have them no matter what browser you run for sure something you should look into. i was able to console.log(data) and examine it. thats how i knew you were on the right track…then it gave me the needed info to get the quotes working…look into dev tools

your next challenge is to get the data to be there on page load and have a new quote on every click!

@benjaminadk Your Codepen throws 404 Error, hence I am not able to view your code. I came to know about CORS for accessing Cross Origin Resourse. But I am not able to access the response with my code. Please help me.
My code :

$(".btn-primary").on(“click”,function(){
$.ajax({
url:“https://quotesondesign.com/wp-json/posts?filter[orderby]=rand”,
type:‘GET’,
datatype:JSON,
headers: {
‘Access-Control-Allow-Headers’:true
},
success:function(data){
var quote=data.shift();
console.log(quote[0].content);
}
});

});

Error shown on console:
XMLHttpRequest cannot load https://quotesondesign.com/wp-json/posts?filter[orderby]=rand. Request header field Access-Control-Allow-Headers is not allowed by Access-Control-Allow-Headers in preflight response

i changed the https for http… one of then should work

@s1d4rt4 Thanks. Can u explain why did i get that error in console?..

Really appreciate your Help…

it seems not all the apis support https (http secure) so, if your code, that seemed good to me, did not work with one, the other should do.