I am having a hard time with javascript promises as a learner. I am building a small react app where you can type in a location and via basic api handling, get the weather.
However, as a twist I am trying to incorporate the user's current location by default. However the issue I am facing is that I can't get the data out of the promise object.
const currentLocation = new Promise((resolve, reject) => {
if(!window.navigator.geolocation) reject('User disabled location checking')
else {
window.navigator.geolocation.getCurrentPosition((position) => {
resolve(`${position.coords.latitude},${position.coords.longitude}`)})}
})
When I keep my location on, the promiseResult comes out as intended, but when I try to pass const currentLocation somewhere, it is passing in the whole promise object and not just the result. What am I missing here?