navigator.mediaDevices.enumerateDevices() returns empty labels

I was having the same issue, turns out it was to do with permissions on accessing direct files, so you will need to put it on localhost if that is your issue.


navigator.mediaDevices.enumerateDevices() will return an empty label attribute value if the permission for accessing the mediadevice is not given. Try using it after getUserMedia.

(async () => {   
  await navigator.mediaDevices.getUserMedia({audio: true, video: true});   
  let devices = await navigator.mediaDevices.enumerateDevices();   
  console.log(devices); 
})();