files/en-us/web/api/usb/getdevices/index.md
{{APIRef("WebUSB API")}}{{SeeCompatTable}}{{SecureContext_Header}}{{AvailableInWorkers}}
The getDevices method of the {{DOMxRef("USB")}} interface
returns a {{JSxRef("Promise")}} that resolves with an array of {{DOMxRef("USBDevice")}}
objects for paired attached devices. For information on pairing devices, see
{{DOMxRef("USB.requestDevice()")}}.
getDevices()
None.
A {{JSxRef("Promise")}} that resolves with an array of {{DOMxRef("USBDevice")}} objects.
The following example logs the product name and serial number of paired devices to the console. For information on pairing devices, see {{DOMxRef("USB.requestDevice","USB.requestDevice()")}}.
navigator.usb.getDevices().then((devices) => {
console.log(`Total devices: ${devices.length}`);
devices.forEach((device) => {
console.log(
`Product name: ${device.productName}, serial number ${device.serialNumber}`,
);
});
});
{{Specifications}}
{{Compat}}