Help with JSON from API

Help with JSON from API


I’m having some trouble retrieving a random quote from an API for my random quote generator. Could anybody point out what I’m doing wrong or provide any tips? Should I be using a different API?

I’m using this API:

Here’s a link to my test CodePen:

Here’s the pasted code (from a button press)

$(document).ready(function() {
$("#new-quote").on(“click”, function(){
$.getJSON(“”, function(json) {


If you check the browser console, you have a CORS error (you can google the error in the console for more info).

I usually solve it by adding ?callback=? at the end of the API URL. But it seems for this API, you have to do it like this, which should achieve the same result as callback=? (which converts the request to jsonp).


Thank you so much!

I was starting to get a bit frustrated because it seemed like I had everything right. Now I’m off to read up on JSONP. Is this covered further in FCC?

20 internet points for you!



When something goes wrong, be sure to check the browser console and google any errors you see.