I am having trouble getting the geolocation coordinates returned from a promise function. I am using the code below which from here: How geolocation.getCurrentPosition return value?
const getPosition = () => {
return new Promise((res, rej) => {
navigator.geolocation.getCurrentPosition(res, rej)
});
}
export const getGeolocation = () => {
getPosition().then(console.log)
}
I tried:
export const getGeolocation = () => {
return getPosition().then(result => return result)
} // doesnt work
Can someone explained to me what is the correct way to get values out of a promise? Thanks