Reputation:
I am having trouble on getting the latitude , what i've tried so far is searchLocation.findLocationByAddress.geoCode.latitude
and i get this error
error
LocationAdd.js:288 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'latitude')
here is my code
const { data: searchLocation } = await getLocations({
variables: {
placeSearch: {
address: value
},
},
});
console.log(searchLocation.findLocationByAddress)
geoCode = {
latitude: searchLocation.findLocationByAddress.geoCode.latitude,
longitude: searchLocation.findLocationByAddress.geoCode.longitude,
};
Upvotes: 0
Views: 84
Reputation: 354
findLocationByAddress returns an array, I think you should call .map() or access an element with [].
Upvotes: 1