Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

119
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda