Skip to content

Instantly share code, notes, and snippets.

@chris-kobrzak
Created October 20, 2021 16:05
Show Gist options
  • Save chris-kobrzak/566aa9253b5a098dee85757bebde3de7 to your computer and use it in GitHub Desktop.
Save chris-kobrzak/566aa9253b5a098dee85757bebde3de7 to your computer and use it in GitHub Desktop.
Promisified navigator.geolocation.getCurrentPosition
function getCurrentPositionTask(positionConfig) {
const { geolocation } = navigator
return new Promise((resolve, reject) => {
const handleSuccess = ({ coords }) => {
resolve(coords)
}
const handleError = error => { reject(error) }
geolocation.getCurrentPosition(handleSuccess, handleError, positionConfig)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment