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

216
Views
Returned promise value always undefined

I'm getting data from a promise that returns a string:

const connectedDevice = async () => {
   await BleClient.getConnectedDevices(optionalServices)
   .then(
      value => { return value[0].deviceId ) };
   )
   .catch(err => { console.log(err) });
}

and I've been calling the function connectedDevice() which reuslts in the string raturned by the promise being output to the console as expected.

However, if I try to use the promise string outside of the function itself, I was getting the promise itself being returned rather than the result of the promise. So, I modified my call to the function by adding await, like so:

const conn = await connectedDevice();

However conn is now just 'undefined' and I'm unsure of what I'm doing wrong.

How do I get the actual value of value[0].deviceId returned so that I can use the promise returned value outside of the connectedDevice() function?

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!