Random Quote API issue

Hello, I had my project working last night via a heroku app someone had built for this project. It has since gone down so i was looking to set it up with something a bit more stable. I’m having trouble getting the GET request to go through properly.

Here is my code

    //make call to quote api and output generated html
    quoteBtn.addEventListener('click', function() {
      $.ajax('https://cors-everywhere.herokuapp.com/http://api.forismatic.com/api/1.0/?method=getQuote&key=1&lang=en&format=jsonp&jsonp=?', {
        dataType: 'jsonp',
        contentType: 'application/jsonp',
      success: function (res) {
       html += "<p class='lead'>" + res.quote + "</p>" + "<br>" + "<p>" + "- " + res.author + "</p>" + "<br>";
        //output html to page
        output.innerHTML = html;
        //<p>res.quote</p>
        //res.author
        html = '';
        }
      });
    });

If i remove the cors-everywhere part i get a mixed content cors issue and the request is blocked. If i use the cors-everywhere app, the GET request fails everytime. Any help would be much appreciated?

Here is the live version as well. Thanks!

Hi,
Try using json instead of jsonp

If i change the jsonp to json i get this failed GET request?

GET https://cors-everywhere.herokuapp.com/http://api.forismatic.com/api/1.0/?me…&format=json&json=jQuery31105688002108226049_1496153379822&_=1496153379823

Looks like you didn’t change the dataType in your ajax call.

//make call to quote api and output generated html
quoteBtn.addEventListener('click', function() {
  $.getJSON('https://cors-everywhere.herokuapp.com/http://api.forismatic.com/api/1.0/?method=getQuote&key=1&lang=en&format=json&json=?', {
    dataType: 'json',
  success: function (res) {
   html += "<p class='lead'>" + res.quote + "</p>" + "<br>" + "<p>" + "- " + res.author + "</p>" + "<br>";
    //output html to page
    output.innerHTML = html;
    //<p>res.quote</p>
    //res.author
    html = '';
    }
  });
});

I had tried that only after i posted :slight_smile: No luck so far. Could it be that codepen doesn’t like any workarounds for http api calls?

Looks like the forsmatic API is no longer supported. Onto a different one then :sweat_smile:

Thanks!

Hey @cperry24!

Just to update, I spoke with the Forismatic API owner and he has updated the app. You should be able to use it :slight_smile:

Awesome! I used the quote design API. Thanks for the update. Had to make sure I wasn’t losing my mind haha