Skip to content

Instantly share code, notes, and snippets.

@ajess33
Created Mar 19, 2018
Embed
What would you like to do?
[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