Skip to content

Instantly share code, notes, and snippets.

@koekaverna
Forked from varmais/thinced.js
Created April 2, 2017 09:48
Show Gist options
  • Save koekaverna/be90b6fa1f652eee736e3c4922460137 to your computer and use it in GitHub Desktop.
Save koekaverna/be90b6fa1f652eee736e3c4922460137 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