Hey guys, I’m working on the Local Weather Project and I’ve been stuck on this code for a couple days now. I keep getting this error. I only call getCurrentPosition in the script so I’m not sure why currentPosition is undefined.
Here is my JS:
$.get("https://ipinfo.io", function(response) {
$("#location").html(response.city + ', ' + response.region);
}, "jsonp");
$(document).ready( function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (callAPI) {
});
}
function callAPI(position) {
var lat = "lat=:" + position.coords.latitude;
var lon = "lon=:" + position.coords.longitude;
var weatherurl = "https://fcc-weather-api.glitch.me/api/current?" + lat + '&'+ lon;
$.ajax ({
url: weatherurl, success: function (data) {
$('#desc').text(data.weather[0].main)
}
});
}
});
Thanks in advance for the help!