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