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

220
Views
la función que verifica la respuesta de la promesa devuelve Promise { <pending> } en lugar de verdadero o falso

Tengo un código nodejs utilizado para recuperar datos de la API de Google Maps:

 const mapsAPI = new Client({}); let countryData = mapsAPI.reverseGeocode( { params: { latlng: latlng, // there's probably a better way of doing this key: process.env.GOOGLE_MAPS_API_KEY, }, timeout: 1000, // in miliseconds }) .then((response) => { // console.log(response.data.results[0].reverseGeocode); // prints whole response // console.log(response.data.results[7].types); // prints types 'country' and 'political' // console.log(response.data.results[7].formatted_address); // prints country country = response.data.results[7].formatted_address; console.log(country); return country; }) .catch((e) => { console.log(e.response.data.error_message); // NOTE: this will only return API errors }); // i know the code is a mess, will fix later // maybe could make this a function and just return response data async function checkAddress() { const a = await countryData; // console.log(a); if (a === 'United States') { console.log('true'); return true; } else { console.log('false'); return false; } return false; } console.log(checkAddress()); // returns Promise { <pending> } for some reason

checkAddress() debería devolver verdadero o falso, pero devuelve Promise { <pending> }, ¿qué estoy haciendo mal?
nuevo en async espera, por favor no me mates

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!