Hello - I am new to retool & javascript so please bear with me.
I am trying to execute the following code off the click event of a button:
try {
console.log('Requesting any Bluetooth device...');
const device = await navigator.bluetooth.requestDevice({
acceptAllDevices: true
});
console.log('> Requested ' + device.name + ' (' + device.id + ')');
}
catch(error) {
console.log('Argh! ' + error);
}
However, when it runs, I receive the following:
SecurityError: Failed to execute 'requestDevice' on 'Bluetooth': Must be handling a user gesture to show a permission request.
Does this fail because js code executes in a sandbox? If not, is there a way to address this or is there another way to handle this? The code is from this resource:
https://googlechrome.github.io/samples/web-bluetooth/get-devices-async-await.html
Thanks in advance for the help.