I want to create a file of functions to be used in other files:
location.js file:
function state() {
navigator.permissions.query({ name: "geolocation" }).then((pos) => {
return pos.state;
});
}
function ask() {
navigator.geolocation.getCurrentPosition((pos) => {
return pos.coords;
}, (err) => {
return err;
});
}
functions...
export {state, ask};
another file:
import * as location from "location.js"
console.log(location.state());
console.log(location.ask());
how to return pos.state
in the first function (return the result, not the promise) and the pos.coords
in the second one?