getJSON function does not return any Data

Can anyone help me figure out why this code doesn’t return any data?

function getQuote(){
var url = “";
$.getJSON(url, function(data){
$(”.quote").html(’"’ + data.quoteText + ‘"’);
$(".author").html(’~ ’ + data.quoteAuthor);

Thanks for Help!

Can you post a link to your codepen?

I suspect it’s a CORS issue. Check out your browser console when making the API call.

Here’s the link :slight_smile:

A few other people (here and here) also posted this same error:

Refused to execute script from '' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

I’m not sure how to fix this (and it seems it’s an issue on their side). You need to look for other APIs to use (I don’t know of any though :disappointed_relieved: ) (or just hardcode quotes in your code).

thanks for your help :), anyway, you have some API suggestions?

We are told to use API on this project, I should use it though. :slight_smile:

I’m not aware of this. AFAIK, using APIs is not required. Can you tell me where you read this?

Thanks for this, I’m sorry, I just thought about it, just to master API. hehe Thanks again.

I did find another API It requires a (free) Mashape Marketplace account. I wound up using this one.

Another nice thing about it: it doesn’t seem to require JSONP.

It’s working already using the first one you give :slight_smile: