I have been trying to get the lat and lng out of this function for a while but I am really at a loss as to why I can't return it. It console.logs it within the function just fine.
Can some help me to provide a solution to return the lat and lng?
<script>
function latLngFind(postcode){
var location = postcode + ' United Kingdom'
axios.get('https://maps.googleapis.com/maps/api/geocode/json',{
params:{
address:location,
key:'my key'
}
})
.then(function(responce){
lat = (responce.data.results[0].geometry.location.lat);
lng = (responce.data.results[0].geometry.location.lng);
console.log([lat,lng]);
return[lat,lng];
})
.catch(function(error){
console.log(error);
});
}
postcode = 'S404UH'
console.log(latLngFind(postcode));
</script>