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

108
Views
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 answers
Answer question

0

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

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