Created
October 20, 2021 16:05
-
-
Save chris-kobrzak/566aa9253b5a098dee85757bebde3de7 to your computer and use it in GitHub Desktop.
Promisified navigator.geolocation.getCurrentPosition
This file contains hidden or 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 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