How to get the JSON data from url using JavaScript. I tried the following but it does not give the json data.
var GetLocation = function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
}
else {
alert("Geolocation is not supported by this browser.");
}
}
function showPosition(position, http) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var app_id = '6784429f5eff661309aaa5280a143f97';
var api = "http://api.openweathermap.org/data/2.5";
var weather_api = api +"/weather?appid="+app_id+"&lat="+lat+"&lon="+lon+"&units=metric";
// console.log(weather_api);
var a = http.get(weather_api).then(function(response){
position.jsonList=response.data;
});
console.log(a);
}
When print the weather_api it gives complete url but i am stuck in how to get the json data from that url.