[Vuejs]-How to return geolocation response object to be used in different components?

0👍

You need to return the promise in your function to get the result in your locationData variable

// In CommonMethod.js

export const getLocationData = async () => {
  return navigator.geolocation.getCurrentPosition(
    success => {
      console.log("SUCCESS", success);
      return success;
    },
    error => {
      console.log("ERROR", error);
      return error;
    }
  );
};

`

Leave a comment