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!
No luck so far. Could it be that codepen doesn’t like any workarounds for http api calls?