api openweather

$(document).ready(function(){ var lat; var long; var temp; if(navigator.geolocation){ navigator.geolocation.getCurrentPosition(function(position){ lat = position.coords.latitude; long = position.coords.longitude; //$("#data").html("latitude: " + lat + "<br>longitude: " + long); //create API with geolocation var wpid = navigator.geolocation.watchPosition(geo_success, geo_error, geo_options); var api = 'http://api.openweathermap.org/data/2.5/weather?lat='+lat+'&lon='+long+'appid=b1b15e88fa797225412429c1c50c122a1'; $.getJSON(api, function(data){ //JSon call for OpenWather API var weatherType = data.weather[0].description; var kelvin = data.main.temp; var winSpeed = data.win.speed; var city = data.name; console.log(api); console.log(city); }); }); } });
freecodecamp challenge

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.