Skip to content

Instantly share code, notes, and snippets.

@douglaszaltron
Forked from varmais/thinced.js
Created August 31, 2018 20:14
Show Gist options
  • Save douglaszaltron/c6fa2159805dafc936ebd558c3185fc3 to your computer and use it in GitHub Desktop.
Save douglaszaltron/c6fa2159805dafc936ebd558c3185fc3 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);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment