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

217
Vistas
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
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