title: How to return value to global variable from asyn/await function?
body: <p>I want to return the user's geolocation to the variable so other function can use it later. I tried using async/await function but it doesn't work. What have I done wrong?</p>
  
  <pre><code>// Getting data
  class Data {
    static async getLatitude() {
      let latitude = await navigator.geolocation.getCurrentPosition((position) =&gt; {
        return position.coords.latitude;
      });
      return latitude;
    }
  
  }
  
  
  // Site running
  window.addEventListener('load', () =&gt; {
    if(navigator.geolocation) {
      let latitude = Data.getLatitude();
      console.log(latitude);
  
    }
  })
  
  </code></pre>