Problem with reading API

Problem with reading API
0

#1

So i’m trying to make a weather app but can’t seem to get data out of the API.
Here is the code:
var api= “https://api.darksky.net/forecast/879f3d4aa91c701894de75f31f8c6773/56,24

$.getJSON(api, function(data){
console.log(data.currently.summary);
});
});
The console is empty and i don’t know what i did wrong…


#2

Try logging the data instead to see what is there.


#3

Tried that aswell…
Here is the code pen: https://codepen.io/ArmoredCub/pen/vZxpqB


#4

If you look at the console it says $ is not defined, did you import jQuery?


#5

That was the first thing i did but for me it does not even show that in the console


#6

Seems like this is the issue https://darksky.net/dev/docs/faq#cross-origin


#7

So it’s denying access to the API because of the key? Is there any way to fix that?


#8

I would suggest you to use another API such as openweather, in fact I now remember that I faced the same issue as you when I did my project.

Search here in the forums, there are probably workarounds.


#9

Ok thanks for the help!


#10

the apixu api helped me with building this app

https://www.apixu.com/

Hope it can help!