Trouble with weather api

Trouble with weather api
0.0 0

#1

Hi, I’m trying to get the weather api to do something–anything–and not having much luck. I tried using “http://” and “https://” and can’t seem to get any response at all. When I copy and paste the url in the browser window I get all the data back, so it must not be the url, right? I made sure jquery was added…I watched some tutorial videos…can’t figure out what I’m doing wrong.

What am I missing? Here’s a link to my codepen:


#2

Hi,

You need the http://

Also, just checking, but did you replace the {my key} with your API key in your actual code?

I think you need to console log data rather than data.coord,.


#3

Do you have a CodePen to link to?


#4

Thanks, I added the http and also tried console.log(data), but still not getting anything. I keep tweaking different things and can’t seem to get a response. I also double checked to make sure the key was actually in there. Good call, though. I figure there’s could be some small easy thing that I am just forgetting or not seeing. Let me know if you have think of anything else. Thanks!


#5

Sure, I just changed the original post so it has a link. Hope someone can help me figure it out, thanks!


#6

Hi, I’m on my phone (it’s 2am here) so can’t really tinker with your code.

I’m on the same project too, and I struggled with the API request format at first too. read documentation on open weather, you have to dig a bit but it’s there.

Also, I didn’t try and store the the response in a variable. I did it as part of a function. I’m not certain if you can just store the response in a single variable like that as your response will have objects and arrays in it.


#7

Haha, maybe coding is a good hobby for insomniacs!

Cool, well thanks for taking a look. I’ve been tinkering and reading for what seems like a long time and can’t seem to figure this out. I’ll keep working on it, but if you see anything please let me know. I’ve been stuck a few times before and eventually made it through, but this one seems to have really stumped me.


#9

Yes! I love you, sir or mam! Thank you, that fixed it right away.

Plus I don’t think I’ll make that mistake again!