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

95
Views
Valor de retorno de Geocode Promise

Estoy usando la API de react-geocode para obtener coordenadas de una dirección de cadena (como 1234 home street, etc.). Hasta ahora, este es mi código.

 async function ConvertAddress(address) { if (address !== "") { Geocode.fromAddress(address, resolve).then( (response) => { const { lat, lng } = response.results[0].geometry.location; const center = { lat: lat, lng: lng}; // if I console logged center from here, it would work fine. return center; }, (error) => { alert("ConvertAddress error:", error); } ); } }

Sin embargo, no estoy seguro de cómo acceder al "centro" desde fuera de esta función (como desde otra función). He intentado esto:

 console.log("ConvertAddress test", ConvertAddress(data[0]));

Y me devuelve esto:

 ConvertAddress test Promise { <state>: "fulfilled", <value>: undefined }​ <state>: "fulfilled"​ <value>: undefined​ <prototype>: Promise.prototype { … }

¿Puedo tener alguna ayuda con el centro de devolución de tal manera que pueda llamarlo sin que esté indefinido? Gracias por adelantado.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prueba esto

 async function ConvertAddress(address) { if (address !== "") { var addressResult = await Geocode.fromAddress(address, resolve).then( (response) => { const { lat, lng } = response.results[0].geometry.location; const center = { lat: lat, lng: lng}; // if I console logged center from here, it would work fine. return center; }, (error) => { return "error in results" } ); addressResult.then(function(result){ console.log(result); }) } }
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!