# getJSON function does not return any Data

**URL:** <https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856>\
**Category:** General\
**Created:** [April 24, 2017, 6:21am UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856 "2017-04-24T06:21:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ewojjowe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ewojjowe/32/43437_2.png) [@ewojjowe](https://forum.freecodecamp.org/u/ewojjowe)\
**Post date:** [April 24, 2017, 6:21am UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856/1 "2017-04-24T06:21:28Z")

</div>

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

function getQuote(){  
var url = “[http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?";](http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?%22;)  
$.getJSON(url, function(data){  
$(”.quote").html(’"’ + data.quoteText + ‘"’);  
$(".author").html(’~ ’ + data.quoteAuthor);  
});  
};

Thanks for Help!

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [April 24, 2017, 8:03am UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856/2 "2017-04-24T08:03:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ewojjowe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ewojjowe/32/43437_2.png) [@ewojjowe](https://forum.freecodecamp.org/u/ewojjowe)\
**Post date:** [April 24, 2017, 8:19am UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856/3 "2017-04-24T08:19:45Z")

</div>

Here’s the link 🙂

> **[Random Quotes Machine](https://codepen.io/ewojjowe/pen/GmqGqj)**
>
> ...

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [April 24, 2017, 8:29am UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856/4 "2017-04-24T08:29:41Z")

</div>

A few other people ([here](https://forum.freecodecamp.com/t/random-quote-generator-mime-type-error/108787) and [here](https://forum.freecodecamp.com/t/quote-generator-help-with-jsonp/104639/7)) also posted this same error:

```nohighlight
Refused to execute script from 'http://api.forismatic.com/api/1.0/...' 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 😥 ) (or just hardcode quotes in your code).

---

<div class="post-metadata">

**Author:** ![ewojjowe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ewojjowe/32/43437_2.png) [@ewojjowe](https://forum.freecodecamp.org/u/ewojjowe)\
**Post date:** [April 24, 2017, 8:51am UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856/5 "2017-04-24T08:51:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ewojjowe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ewojjowe/32/43437_2.png) [@ewojjowe](https://forum.freecodecamp.org/u/ewojjowe)\
**Post date:** [April 24, 2017, 8:53am UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856/6 "2017-04-24T08:53:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [April 24, 2017, 8:59am UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856/7 "2017-04-24T08:59:16Z")

</div>

> **[Random Quote Generator For Campers!](https://forum.freecodecamp.org/t/random-quote-generator-for-campers/22867)**
>
> Hello fellow campers. I just finished putting together a random quote generator for anyone to use in their projects. There is currently 50 quotes in the database. I put this together both for fun and as a way to give to the community. Please let...

> **[Quotes API for your project](https://forum.freecodecamp.org/t/quotes-api-for-your-project/70953)**
>
> I finished the quotes application a few days ago, but I have noticed many campers struggling with an API, so I made mine public. You should either get all the quotations from: https://mysterious-sierra-49778.herokuapp.com/api/quotations Or get...

> [@ewojjowe](#):
>
> We are told to use API on this project

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

---

<div class="post-metadata">

**Author:** ![ewojjowe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ewojjowe/32/43437_2.png) [@ewojjowe](https://forum.freecodecamp.org/u/ewojjowe)\
**Post date:** [April 24, 2017, 9:05am UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856/8 "2017-04-24T09:05:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andrewdski](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/andrewdski/32/49341_2.png) [@andrewdski](https://forum.freecodecamp.org/u/andrewdski)\
**Post date:** [April 24, 2017, 3:13pm UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856/9 "2017-04-24T15:13:56Z")

</div>

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

> **[Random Famous Quotes API Documentation](https://market.mashape.com/andruxnet/random-famous-quotes)**
>
> Random Famous Quotes API Documentation. Get a random quote in JSON format. Current categories are:
> \- famous
> \- movies

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

---

<div class="post-metadata">

**Author:** ![ewojjowe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ewojjowe/32/43437_2.png) [@ewojjowe](https://forum.freecodecamp.org/u/ewojjowe)\
**Post date:** [April 24, 2017, 3:28pm UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856/10 "2017-04-24T15:28:06Z")

</div>

It’s working already using the first one you give 🙂

> **[Random Quotes Machine](https://codepen.io/ewojjowe/full/GmqGqj)**
>
> ...

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 9:37am UTC](https://forum.freecodecamp.org/t/getjson-function-does-not-return-any-data/108856/11 "2021-01-17T09:37:44Z")

</div>

Closed on January 17, 2021, 9:37am UTC


