Hello everyone ! I was working on my local weather app when I stumbled upon a problem I can’t solve on my own
You see, i’m kind of used to api’s request, and it works perfectly fine when it comes to the FCC api on local weather, but when I tried to use the google’s geolocation api, I kept getting an error message.
here’s the URL to the api : http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true
And here’s how i’m approaching it :
function GetCity(){
$.ajax({
datatype : "json",
contentType : "application/json",
type : "GET",
url : "maps.googleapis.com/maps/api/geocode/json?",
data : {
latlng : "40.714224,-73.961452",
sensor : "true";
},
success : function(quote){
document.getElementById("city").innerHTML = "Success!"
},
error : document.getElementById("city").innerHTML = "Error!"
});
}
obviously i’ll use the returned json later on, but as for now I do not manage to get a success message, and since i’m a total noob with api’s , I thought i’d request help here.
If needed , here’s a link to the codepen : https://codepen.io/Hadrienallemon/pen/rpWgYG
Thanks a lot for anyone reading this, and have a good night !