Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active June 27, 2020 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/9b28f5eeb959fcdbdb1d170d9cae9c9a to your computer and use it in GitHub Desktop.
Save parzibyte/9b28f5eeb959fcdbdb1d170d9cae9c9a to your computer and use it in GitHub Desktop.
/*
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