I get information about location, but can not use it in html.error => Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'geoLocationPlace').Why is the variable(geoLocationPlace)undefined?
data() {
return {
inputValue:null,
searchedPlace:null,
geoLocationPlace:null,
}
},
getLocation(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
let long = position.coords.longitude;
let lat = position.coords.latitude;
fetch(`https://api.bigdatacloud.net/data/reverse-geocode-client?
latitude=${lat}&longitude=${long}&localityLanguage=en`)
.then(res => {
return res.json()
})
.then(resData => {
//resData.countryName return country
this.geoLocationPlace = resData.countryName
console.log(this.geoLocationPlace)
})
})