Last active
June 27, 2020 16:43
-
-
Save parzibyte/9b28f5eeb959fcdbdb1d170d9cae9c9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://parzibyte.me/blog | |
*/ | |
const obtenerUbicacion = async () => { | |
const API_ENDPOINT = "https://freegeoip.app/json/"; | |
const response = await fetch(API_ENDPOINT); | |
const datosUbicacion = await response.json(); | |
// Imprimir los datos de la ubicación | |
console.log(datosUbicacion); | |
// Recuerda que podemos acceder a latitude y longitude, entre otros | |
const latitud = datosUbicacion.latitude, | |
longitud = datosUbicacion.longitude; | |
console.log(`Tus coordenadas son ${latitud},${longitud}`); | |
} | |
obtenerUbicacion(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment