Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

223
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda