Some help required

Ok so I’m struggling here to get my openweathermap Api to read and produce data, using the lat and lon coordinates I’ve given it.

I’m using ip.api.com and this is working, but when I try to pass these into openweather I cannot and I receive this message on the console:

“Failed to load resource: the server responded with a status of 401 (Unauthorized)”

It also shows that my lat and lon have been passed into the URL. Is this a cross origins issue? Should I scrap openweather and use something else like forcast.io, don’t want to mess about signing up for things I dont need to… I’m using Chrome btw.

Weather App Codepen

Hoping someone can at least point me in the right direction here.

I would re-examine the URL you are creating. You need to have “&APPID=” before the api key itself. Also the & symbol is not required before the first parameter.

Thank you, that totally slipped my mind.

You’re not adding the API key correctly to the url, what you’re doing is this: url + apiKey. What you need to do is: url + ‘&APPID=’ + apiKey. Also you have an extra }); at the end of your script that you need to remove.

I thought I’d completed this task, managed to get the temp to change from C to F, It was done. But I’ve done something to make the temperatures really high (unless its an api fault).

I’m not sure what because once it was complete I left the pc for 5 mins, came back and this has happened.

Can anybody see why this has happened? Ignore the rubbish design lol.

K

Weather app

There’s whitespace in your URL between weather? and units=metric on line 5. With that fixed, it works as expected.