JSFiddle - React, Tailwind, and code Playground

by suhail

HTML

<div id="target" style="width: 100px; height: 100px; border: 1px solid red"></div>

JavaScript

$('#target').click(function() {
  chrome.bluetooth.startDiscovery(function() {
    navigator.bluetooth.requestDevice({
        filters: [{
          services: ['battery_service']
        }]
      })
      .then(device => {

        console.log(device);
        return device.gatt.connect();
      }).then(server => {
        console.log(server)
      }).catch(error => {
        console.log(error);
      });
  });
});