MVP #6.1 #82
|
@ -1,8 +1,10 @@
|
|||
export const getLocationDataFromLatAndLong = async (latitude: number, longitude: number) => {
|
||||
const response = await fetch(`https://nominatim.openstreetmap.org/reverse?lat=${latitude}&lon=${longitude}&format=json`)
|
||||
const data = await response.json()
|
||||
console.log(data);
|
||||
|
||||
return {
|
||||
city: data.address.town || data.address.city || data.address.village,
|
||||
state: data.address.country,
|
||||
city: data?.address?.town || data?.address?.city || data?.address?.village,
|
||||
state: data?.address?.country,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue