const filters = [
{ vendorId: 0x1209, productId: 0xa800 },
{ vendorId: 0x1209, productId: 0xa850 },
];
navigator.usb
.requestDevice({ filters })
.then((usbDevice) => {
console.log(`Product name: ${usbDevice.productName}`);
})
.catch((e) => {
console.error(`There is no device. ${e}`);
});USB: requestDevice() method / notebook
USB: requestDevice() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
navigator.usb
.requestDevice({
filters: [{ vendorId: 0x1209 }],
exclusionFilters: [{ vendorId: 0x1209, productId: 0xa850 }],
})
.then((usbDevice) => {
console.log(`Product name: ${usbDevice.productName}`);
})
.catch((e) => {
console.error(`There is no device. ${e}`);
});