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