Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 27, 2020 16:24
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/1d93b6c47c67740ba0fcd24669fadb91 to your computer and use it in GitHub Desktop.
Save parzibyte/1d93b6c47c67740ba0fcd24669fadb91 to your computer and use it in GitHub Desktop.
/*
https://parzibyte.me/blog
*/
const API_ENDPOINT = "https://freegeoip.app/json/";
fetch(API_ENDPOINT)
.then(response => response.json())
.then(datosUbicacion => {
// 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}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment