Created
March 19, 2018 23:06
-
-
Save ajess33/28986581b98e78de7cc55395dd8d4569 to your computer and use it in GitHub Desktop.
[object HTMLDivElement] firefox error
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
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