Tauri28
Tauri28

Reputation: 908

WebUSB getDevices empty list

Running Chrome 56.0.2924.76 (64-bit) on Windows 10 PRO Version 1511 (OS Build 10586.753). Have enabled experimental-web-platform-features on chrome, running it with flag --disable-webusb-security and as administrator. I try to get USB device list on localhost (using https) with getDevices but I get empty list, although chrome://device-log is showing me plenty of devices. What could be the issue?

navigator.usb.getDevices().then(function(devices){
    console.log(devices);
});
// console outputs []

Upvotes: 10

Views: 8031

Answers (1)

Supersharp
Supersharp

Reputation: 31161

You should use requestDevice() before in order to get access permissions on selected devices.

navigator.usb.requestDevice({filters:[]}).then(function(device){
   console.log(device);
});

After that you'll be able to call getDevices().

Upvotes: 31

Related Questions