Local weather help

Local weather help


Got coordinates to display but that’s it. Just wondering why temperature is not displaying correctly for me.

Also unrelated, though I haven’t started it yet, what’s the best way to convert from F to C and vice versa with a click of a button?

Thanks in advance.


from what i see in a brief look at your code is that you have in dev tools is that your request to darksky is not working.

i did a console log of data and fTemp and got this error. i havent used darksky but see where it says undefined undefined in the error. that is where your lat and long are supposed to be. i would start by going to darksky and making sure you have the syntax of the api request right.


got it

okay i figured it out. i forked u and here it is…you had lat and long defined inside theif(navigator.geolocation....) statement but were trying to access the lat and long variables outside of the scope in which they were defined…i shuffled things around and added a proxy. hope that helps the first part of your ??

As for temp conversion

check out my weather app

side note

dev tools can be super useful once you get used to it…it looks like a bunch of nonsense at first but by taking a couple minutes and using some console.logs i was able to diagnose your problem. i used chrome browser and there are tons of resources out there, including here, that teach about dev tools…and i only know a small portion of what it can do at this point


Thank you for your help! Just curious how adding a proxy made the temperature appear instead of just using the darksky api alone.

And you’re right, I should use the console more to troubleshoot more when I run into problems. I’m still very new to all this, so I make a lot of silly mistakes.


the proxy didnt make it appear. it was the scope issue. however, when i went to darksky api site they said to add a proxy to protect your api key when you make requests.


before lat and long were coming back as undefined when you made the get request to darksky, this is because you had initialized lat and long but not defined them in the beginning of your program. you defined lat and long when you made your navigator.geolocation call BUT that was inside the get function in the if statement. so when you tried to use those versions of lat and long to get the weather the program went to your initial lat and long NOT the lat and long with the actual data…sorry its hard to explain but it was for sure a scope thing.

var a = 2;

function example(){
var a = 1;


so you will get two different values for a in this example if that helps make sense of it. copy and paste it and play with it to get a feel for scope

no worries

i am new as well and am just passing on some stuff that has helped me. trust me i am a newb. but no prob i like helping when i can. peeps here have helped me a ton.


To create a click button to convert F and C, I would suggest you to have both F and C first, and create a variable (for example, var isCel), and set it to either true or false. So when you click the button, it goes through an if statement. If it is false, it displays the same unit (eg if isCel = false, and the button is clicked, it changes it from F to C), and sets the value to true. And if it is true already, it displays the opposite unit, and sets the value to false.


Thanks for all the help guys, the community is awesome. :thumbsup: