.
This commit is contained in:
parent
4ebc9a7368
commit
b564c2c302
1 changed files with 4 additions and 3 deletions
|
|
@ -56,7 +56,8 @@ function obterViaBrowser(): Promise<{ latitude: number; longitude: number }> {
|
|||
}
|
||||
|
||||
async function obterViaGeoIp(): Promise<{ latitude: number; longitude: number }> {
|
||||
const resp = await fetch("http://ip-api.com/json/?fields=lat,lon")
|
||||
const dados: { lat: number; lon: number } = await resp.json()
|
||||
return { latitude: dados.lat, longitude: dados.lon }
|
||||
const resp = await fetch("https://ipapi.co/json/")
|
||||
if (!resp.ok) throw new Error(`GeoIP falhou: ${resp.status}`)
|
||||
const dados: { latitude: number; longitude: number } = await resp.json()
|
||||
return { latitude: dados.latitude, longitude: dados.longitude }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue