Skip to content

Instantly share code, notes, and snippets.

@mCzolko
Created October 3, 2022 10:47
Show Gist options
  • Save mCzolko/f8673cde02fadc299cf3a9fe52417c63 to your computer and use it in GitHub Desktop.
Save mCzolko/f8673cde02fadc299cf3a9fe52417c63 to your computer and use it in GitHub Desktop.
Geolocation typescript function
const geolocation = (): Promise<GeolocationPosition> => new Promise((resolve, reject) => {
const geo = navigator.geolocation
if (!geo) {
reject('Geolocation is not supported')
return
}
geo.getCurrentPosition(
resolve,
err => reject(err.message)
)
})
export default geolocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment