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

121
Views
Pass data from one window to another in React

Hello everyone I have the following code to take the location I need to use those values to send them to another page or component if someone could help me it would be very useful greetings

      const processManualLocation = () => {
        const  url = `https://www.googleapis.com/geolocation/v1/geolocate?key=.........`;
        const http = new XMLHttpRequest();
        http.open("POST", url);
        http.onreadystatechange = function(){
          if(this.readyState == 4 && this.status == 200){
           let resultado = JSON.parse(this.responseText);
           let latitude = resultado.location.lat;
           let longitude = resultado.location.lng;
           console.log(latitude, longitude);
          }
        }
        http.send();
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It seems like you're trying to use the Google Geolocation API.

Here's an example of a asynchronous function for fetching data from that endpoint:

TS Playground

// Ref: https://developers.google.com/maps/documentation/geolocation/overview

const API_KEY = `Your actual API key`;

async function processManualLocation () {
  const  url = `https://www.googleapis.com/geolocation/v1/geolocate?key=${API_KEY}`;
  const request = new Request(url, {method: 'POST'});
  const response = await fetch(request);
  if (!response.ok) throw new Error('Response not OK');
  const data = await response.json();
  const {accuracy, location: {lat, lng}} = data;
  const result = {accuracy, lat, lng};
  console.log(result);
  return result; // or whatever want to return from the response data
}
about 4 years ago · Juan Pablo Isaza Report
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!