Created
August 13, 2019 18:08
-
-
Save cms/2d571ed4cdd843f81f229a2bc22a9aef to your computer and use it in GitHub Desktop.
navigator.geolocation.getCurrentPosition promise
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 getCurrentPosition(options) { | |
return new Promise(function(resolve, reject) { | |
navigator.geolocation.getCurrentPosition(resolve, reject, options); | |
}); | |
} | |
(async () => { | |
const position = await getCurrentPosition().catch(err => console.log(err)); | |
console.log(position); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment