Skip to content

Instantly share code, notes, and snippets.

@ajess33
Created March 19, 2018 23:06
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 ajess33/28986581b98e78de7cc55395dd8d4569 to your computer and use it in GitHub Desktop.
Save ajess33/28986581b98e78de7cc55395dd8d4569 to your computer and use it in GitHub Desktop.
[object HTMLDivElement] firefox error
function getPosition() {
if (navigator.geolocation) {
// store location
navigator.geolocation.getCurrentPosition(fetchData);
console.log('Location Available');
} else {
// no location
console.log('No Location Available');
}
}
var location = document.querySelector('.location');
var icon = document.querySelector('.icon');
function fetchData(position) {
latitude = position.coords.latitude;
console.log(latitude);
longitude = position.coords.longitude;
console.log(longitude);
// add to location div
fetch(
'https://fcc-weather-api.glitch.me/api/current?lat=' +
latitude +
'&lon=' +
longitude
)
.then(function(response) {
return response.json();
})
.then(function(data) {
console.log(data);
});
}
getPosition();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment