Having issues with my api links

Hi guys, I’ve been working on this weather app for whole day now but I’m not able to get it working, until now I had a problem with the HTTP and HTTPS over github pages, now when I got the HTTPS api link, im still unable to get the data I want to display on my app

Here is my total javascript code

function toC(K){
	return Math.floor(K-273.15)
}

function toF(K){
	return Math.floor(9/5*(K-273.15) + 32)
}



var temp, pressure, humidity;

$(document).ready(function(){
	var cel= false;
	if (navigator.geolocation){
		navigator.geolocation.getCurrentPosition(function(position){
			$.getJSON("http://cors.io/?u=https://api.darksky.net/forecast/"+ "random code hidden for now" + "/" + position.coords.latitude + ","+ position.coords.longitude, function(data){
				console.log(data);
				$("#weather").html("There is " + data.currently.summary+ " in " + data.timezone);
				temp = data.currently.temperature;
        if (cel == false){
					$("#details").html("Temperature: " + toF(temp) + "°F");
				} else if(cel == true){
					$("#details").html("Temperature: " + toC(temp) + "°C");
				}
      });
		});
	};

	$("#unit-toggle").on("click", function(){
		if (cel == false){
			cel = true;
			$("#details").html("Temperature: " + toC(temp) + "°C");
		} else if(cel == true){
			cel = false;
			$("#details").html("Temperature: " + toF(temp) + "°F");
		}
	});
});

https://darksky.net/dev/docs/faq#cross-origin

EDIT:

I set up a proxy to make darksky API requests from browser: https://darksky8.herokuapp.com/latitiude/longitude

Example https://darksky8.herokuapp.com/41.9/12.4

Heroku dynos go to sleep after 30min so it may take 10…20 seconds for the first request to go through.

Working example:

1 Like