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

104
Vistas
How to handle "Promise { <pending> }" in javascript

I have this function in javascript

const getData = async() => {

try {
    const serviceResponse = await someService("userId")
    return serviceResponse

  } catch (error) {
    console.log(error);
    
  }
}



const data = getData()
console.log(data)

Whenever I am running this I am getting this in console

 Promise { <pending> }

But when I am print data in the function itself I am getting the desired value

const getData = async() =>  {
 try {
     const serviceResponse = await someService("userId")
     console.log.(serviceResponse)

   } catch (error) {
     console.log(error);
    
  }
 }



 getData()

The following function is what I am importing from defined in another another

exports.someService = async(date,locationId,workerType) => {
    const value = await Attendance.find({})

    return value
}

Please can someone explain what is happening ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you need to await the promise from getData() too -

const data = await getData()
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