# APIs - Please help :'(

**URL:** <https://forum.freecodecamp.org/t/apis-please-help/111626>\
**Category:** General\
**Created:** [May 2, 2017, 9:49pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626 "2017-05-02T21:49:19Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeyMcC](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/codeymcc/32/42968_2.png) [@CodeyMcC](https://forum.freecodecamp.org/u/CodeyMcC)\
**Post date:** [May 2, 2017, 9:49pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/1 "2017-05-02T21:49:19Z")

</div>

Hey

I’m really struggling on the random quote generator API and am looking for help. I’ve worked on it all today/yday trying to find a solution but I can’t seem to find out.

Right now I don’t want to format the data, I just want to get my data into the header! I’ve copied the url into a browser which brings up a random quote, I’ve also passed the $.getJSON into the console which did bring in some data, but then I couldn’t get the button/click event to work to pass through to the header.

If this is a button issues over a JSON query I will be very upset…

> **[Random quote generator](https://codepen.io/StephenDRoberts/pen/Kmmejg)**
>
> ...

![](https://global.discourse-cdn.com/freecodecamp/original/3X/6/a/6a6d0f659160adecb448afe3d7611d45c613e297.jpg)

---

<div class="post-metadata">

**Author:** ![AdventureBear](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/adventurebear/32/74786_2.png) [@AdventureBear](https://forum.freecodecamp.org/u/AdventureBear)\
**Post date:** [May 2, 2017, 9:54pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/2 "2017-05-02T21:54:56Z")

</div>

what kind of console errors if any are you getting? I am looking at it now and am getting some, but wondering what you are seeing and what you have tried so far?

EDITED to add: I know you’ve been trying all day…what’s showing RIGHT NOW in your console?

---

<div class="post-metadata">

**Author:** ![CodeyMcC](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/codeymcc/32/42968_2.png) [@CodeyMcC](https://forum.freecodecamp.org/u/CodeyMcC)\
**Post date:** [May 2, 2017, 10:01pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/3 "2017-05-02T22:01:14Z")

</div>

Sorry, I don’t think I understand - currently if I click the button, nothing happens. Nothing comes in the console either.

If, however I put the following section of code into the console:

$.getJSON("[http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en&callback=?"](http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en&callback=?%22), function(json) {  
console.log(json); });

Then I get a bit object of stuff that looks like this:

Object  
-abort: function (a){-}  
-always: function(a)[-]  
-catch function(a)[-]…

…and it goes on for a while.

---

<div class="post-metadata">

**Author:** ![AdventureBear](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/adventurebear/32/74786_2.png) [@AdventureBear](https://forum.freecodecamp.org/u/AdventureBear)\
**Post date:** [May 2, 2017, 10:09pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/4 "2017-05-02T22:09:35Z")

</div>

what browser are you using?

---

<div class="post-metadata">

**Author:** ![CodeyMcC](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/codeymcc/32/42968_2.png) [@CodeyMcC](https://forum.freecodecamp.org/u/CodeyMcC)\
**Post date:** [May 2, 2017, 10:11pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/5 "2017-05-02T22:11:36Z")

</div>

Safari, I’ve not tried anything else tbh

---

<div class="post-metadata">

**Author:** ![AdventureBear](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/adventurebear/32/74786_2.png) [@AdventureBear](https://forum.freecodecamp.org/u/AdventureBear)\
**Post date:** [May 2, 2017, 10:16pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/6 "2017-05-02T22:16:41Z")

</div>

I’m getting some different console errors in Chrome, but can’t get past this error even when I address a few other ones:

```
Refused to execute script from 'https://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en&callback=jQuery31104296265560980701_1493763287940&_=1493763287941' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.

```

I know this is an error that’s come up a lot and I’ve not been successful yet fixing it (having just spent 10-15 min on it). Reading this now:

> <https://stackoverflow.com/questions/24528211/chrome-refuses-to-execute-an-ajax-script-due-to-wrong-mime-type>

The console should be showing you errors. Try using chrome for it’s debugging tools for a few projects.

Try running my pen (a fork of yours) in safari or mozilla, does it work for you?

> **[Random quote generator](https://codepen.io/AdventureBear/pen/ybXRMB?editors=1010)**
>
> ...

---

<div class="post-metadata">

**Author:** ![AdventureBear](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/adventurebear/32/74786_2.png) [@AdventureBear](https://forum.freecodecamp.org/u/AdventureBear)\
**Post date:** [May 2, 2017, 10:23pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/7 "2017-05-02T22:23:17Z")

</div>

And, I’ve decided i’m not uptodate on Cross origin requests to troubleshoot this further today. ☹

But try using a different browser with better deloper tools like firefox or chrome and see if you get any progress. sorry i could not help more.

---

<div class="post-metadata">

**Author:** ![Cowwy](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/cowwy/32/158666_2.png) [@Cowwy](https://forum.freecodecamp.org/u/Cowwy)\
**Post date:** [May 2, 2017, 10:32pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/8 "2017-05-02T22:32:27Z")

</div>

Does this work for you?  
I am not too sure what is not working for you. I just replace my API address and it works.

> **[Random Quote Generator: Forismatic](https://codepen.io/Cowwy/pen/JNJmmy)**
>
> Intermediate Challenge Random Quote API ...

One more thing, codepen doesn’t work for me in Safari. It look all distorted. ☹

---

<div class="post-metadata">

**Author:** ![CodeyMcC](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/codeymcc/32/42968_2.png) [@CodeyMcC](https://forum.freecodecamp.org/u/CodeyMcC)\
**Post date:** [May 2, 2017, 10:37pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/9 "2017-05-02T22:37:07Z")

</div>

yeh that one works. Ive tried it in Chrome as well but its the same as safari. I get nothing in the codepen console, i don’t know if I’m doing it wrong or looking in the wrong place, but console is always blank unless i type into it myself.

---

<div class="post-metadata">

**Author:** ![Cowwy](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/cowwy/32/158666_2.png) [@Cowwy](https://forum.freecodecamp.org/u/Cowwy)\
**Post date:** [May 2, 2017, 10:38pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/10 "2017-05-02T22:38:51Z")

</div>

[http://api.jquery.com/jquery.getjson/](http://api.jquery.com/jquery.getjson/)

```auto
$.getJSON( API, function( ), 'jsonp' );
//add the jsonp part in the mix

```

and then

add this before your api address. This prevents cross-origin issue. Suggest that you look up what that means so you know what it is. [https://en.wikipedia.org/wiki/Cross-origin\_resource\_sharing](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)

```auto
"https://cors-anywhere.herokuapp.com/"

```

But you are still not done. There is one more issue.  
I’ll let you figure that one out 😃

---

<div class="post-metadata">

**Author:** ![AdventureBear](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/adventurebear/32/74786_2.png) [@AdventureBear](https://forum.freecodecamp.org/u/AdventureBear)\
**Post date:** [May 3, 2017, 4:07am UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/11 "2017-05-03T04:07:49Z")

</div>

this looks really nice and clean, good work! I tried implementing your solution in a fork of the OP’s pen, and I still can’t get it to work. Can you spot any errors here? Even though i’ve done this project, I’d still like to konw why I can’t fix the OPs pen!

> **[Random quote generator](https://codepen.io/AdventureBear/pen/ybXRMB?editors=1010)**
>
> ...

---

<div class="post-metadata">

**Author:** ![jenovs](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jenovs/32/60963_2.png) [@jenovs](https://forum.freecodecamp.org/u/jenovs)\
**Post date:** [May 3, 2017, 5:12am UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/12 "2017-05-03T05:12:49Z")

</div>

There was a similar question yesterday, and this was the answer:

> **[Random Quotes with API, button does not work. Help!](https://forum.freecodecamp.org/t/random-quotes-with-api-button-does-not-work-help/111429/2)**
>
> That API is not supported anymore, they know about the issue but won’t do anything about it. I remade it with https://quotesondesign.com/api-v4-0/ just yesterday for that reason

---

<div class="post-metadata">

**Author:** ![Cowwy](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/cowwy/32/158666_2.png) [@Cowwy](https://forum.freecodecamp.org/u/Cowwy)\
**Post date:** [May 3, 2017, 4:11pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/13 "2017-05-03T16:11:45Z")

</div>

The OP API has a callback with no values on it. Remove that it works.

---

<div class="post-metadata">

**Author:** ![CodeyMcC](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/codeymcc/32/42968_2.png) [@CodeyMcC](https://forum.freecodecamp.org/u/CodeyMcC)\
**Post date:** [May 3, 2017, 8:10pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/14 "2017-05-03T20:10:33Z")

</div>

Hi guys

Thanks for all your help. Unfortunately I still couldn’t get it to work. I tried Chrome, putting in jsonp, putting in the heroku line, removing the callback section, trying the other example api and i got nothing. I’m going to try something else for a while before my computer goes out the window.

Thanks again for your input though, all your efforts to help are very much appreciated!

---

<div class="post-metadata">

**Author:** ![czmozynski](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@czmozynski](https://forum.freecodecamp.org/u/czmozynski)\
**Post date:** [May 3, 2017, 8:28pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/15 "2017-05-03T20:28:03Z")

</div>

Hey Pal,

Don’t worry about it Im on the weather app and the JSON call is a nightmare… theres some technical wizardry we weren’t prepared for, if you simply followed the lessons.

My suggestions is start “googling” AJAX JSON call et al… are try and teach yourself this stuff from multiple angles/sources.

On the plus side, this is where most of the “Theory” starts to sink in (and all the jibber jabber will start to have meaning)… it will roll around your head and you’ll start thinking about it from multiple angles.

Good luck… remember they put a picture up of someone punching their screen for a reason. 🙂

---

<div class="post-metadata">

**Author:** ![CodeyMcC](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/codeymcc/32/42968_2.png) [@CodeyMcC](https://forum.freecodecamp.org/u/CodeyMcC)\
**Post date:** [May 3, 2017, 8:48pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/16 "2017-05-03T20:48:08Z")

</div>

Haha, cheers bud. one day I’ll build my confidence back up to try the weather one!

---

<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 16, 2021, 5:59pm UTC](https://forum.freecodecamp.org/t/apis-please-help/111626/17 "2021-01-16T17:59:49Z")

</div>


