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?