NOtherDev / whatwebcando

An overview of the device integration HTML5 APIs
https://whatwebcando.today/
MIT License
837 stars 61 forks source link

Fix nits in Web Bluetooth sample #22

Closed beaufortfrancois closed 8 years ago

beaufortfrancois commented 8 years ago
function readBatteryLevel() {
         services: ['battery_service']
       }]
     })
-    .then(function(device) {
+    .then(function (device) {
       return device.gatt.connect();
     })
-    .then(function(server) {
+    .then(function (server) {
       return server.getPrimaryService('battery_service');
     })
-    .then(function(service) {
-      if (!service) {
-        throw 'Battery Service not found';
-      }
+    .then(function (service) {
       return service.getCharacteristic('battery_level');
     })
     .then(function (characteristic) {
@@ -29,7 +26,7 @@ function readBatteryLevel() {
     .then(function (value) {
       $target.innerHTML = 'Battery percentage is <b>' + value.getUint8(0) + '</b>.';
     })
-    .catch(function(error) {
+    .catch(function (error) {
       $target.innerText = error;
     });
 }
NOtherDev commented 8 years ago

👍 Done.