Need help with forismatic API

Need help with forismatic API
0

#1

I found this challenge a hard one and had to look for additional info online, still having trouble with the whole deal and any help or guidance would be appreciated.

I can’t seem to understand what I’m missing in my code;

My RQM on Codepen


#2

You’ll have to remove the https:// from your pen’s url (view the pen on http)

or use https://crossorigin.me/ in your API url


#3

try this url- when the format is JSONP you have to use a callback=?

  1. http://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&jsonp=?&lang=en&callback=?
    
  2. when testing a JSON to see if the url content is correct you can test it in a 'JSON beautifier'  - http://jsonmate.com

#4

Hey that worked, thanks…BTW any idea why when the author field is empty it does not display “Unknown” although its in an if statement in the script section??


#5

yeah the cross origin worked… I was checking everything… the interesting thing is for mine I did not need the crossorigin

intersting…


#6

I think you swapped these lines:

        if(data.quoteAuthor !== "") {
          $('#content').html(data.quoteText); // this line
        } else {
          $('#author').html("Unknown");
        };          

        $('#author').html(data.quoteAuthor); // and this line



#7

Also if you remove lines 3 and 4: you come is mush smoother when loading…

$("#getQuote").html("Loading..."); $("#getQuote").attr("disabled", true);