Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
How to return geolocation 'state' or 'coords' to be used in different file in javascript?

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!