Skip to content

Instantly share code, notes, and snippets.

@varmais
Created October 1, 2015 19:43
Show Gist options
  • Save varmais/74586ec1854fe288d393 to your computer and use it in GitHub Desktop.
Save varmais/74586ec1854fe288d393 to your computer and use it in GitHub Desktop.
Geolocation to Promise wrap example
var getPosition = function (options) {
return new Promise(function (resolve, reject) {
navigator.geolocation.getCurrentPosition(resolve, reject, options);
});
}
getPosition()
.then((position) => {
console.log(position);
})
.catch((err) => {
console.error(err.message);
});
@dlik
Copy link

dlik commented Jan 6, 2021

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment