Random quote generator wont fetch api data

Random quote generator wont fetch api data
0.0 0

#1

I am trying to start the random quote generator and for what ever reason no matter what i try i cant seem to actually pull in data from an outside site. My code is listed below but please don’t just fix it, just point me in the right direction unless the problem is really obscure.


#2

So, I see a few issues here:

  1. Your CodePen is throwing an error on line 4, with JSON = JSON."quote";. That might be a good place to start looking. :slight_smile: I’ll give you a hint on this one - JSON objects are just like normal JavaScript objects. How would you access values off of a JavaScript object?

  2. It looks like you’re trying to access value for the quote property…except the way it’s structured now, in the callback function, you’re trying to pull something off of this magical JSON (capital is important in this case) object. Where is this object? (This is kind of trick question.) And what does the callback function of .getJSON take as an argument? (This is not at all a trick question.)

  3. Is there a particular reason you’re calling JSON.stringify on json? (In the long run, this is much less important than #2. But always a good practice to ask yourself why you’re doing everything you’re doing!)