I’m back in API hell with the Show the Local Weather project today. Right now I’m in that place where I think I know what I’m doing but it’ll likely fail to work and cause me more anguish than Random Quote did yesterday.
I’m seeing datatype = ‘jsonp’ in your code, which I’m pretty sure should just be ‘json’. You’re also not getting the data from what I see. Under success: is where you should grab the quote and assign it to a variable. The “data” in the function is what’s used to target the api category. So if the api assigns each quote as “quote” then you would say data.quote to target it. I then assigned the api target to a variable, like theQuote = data.quote; and then I was able to use my theQuote variable to use the quotes.
That’s probably really confusing and in this case it’s the blind leading the blind, but that’s the best way I can explain it right now. Hope it helps more than harms >.<
Thanks so much! I must say I don’t understand how the console works, so I don’t exactly see what the problem is. An object appears but there’s something else I’m supposed to understand?
Also, I thought the property name is “quoteAuthor” not sure where “author” comes from
Can you point me to a geolocation api or something? My search just keeps coming up with some HTML 5 Geolocation thing that either refuses to work or isn’t being fully explained by people.
Great, now I can get it to work! I don’t really understand exactly, but knowing how to use the console now maybe there’s a chance for me to figure it out. Thanks so much for all your help!
Honestly it’s been a life-saver for me. I console.log pretty much everything.
Javascript30 gives a lot of tips on how to use the console, it’s free and the videos aren’t long.
Im just going to add that the JSON API AJAX section on Colt Steele’s Advanced Web Developer Bootcamp has the best and easiest to understand resources and examples Ive watched/read