Re: [web-bluetooth] errorSecurityError: Origin is not allowed to access the service. Tip: Add the service UUID to 'optionalServices' in requestDevice() options. https://goo.gl/HxfxSQ

You had a typo in `optionalServices`. See below:

```diff
function search() {
    document.getElementById("demo").innerHTML = "My First JavaScript";
    let options = {
-        optionalServices: ['00000003-0000-1000-8000-00805f9b34fb']
+        optionalServices: ['00000000-0000-1000-8000-00805f9b34fb']
    };
    let filters = [];
    let filterName = document.querySelector('#name').value;
    if (filterName) {
        filters.push({
            name: filterName
        });
        options.filters = filters;
    } else {
        options.acceptAllDevices = true;
    }

    navigator.bluetooth.requestDevice(options).then(device => {
        return device.gatt.connect();

    }).then(server => {
        document.getElementById("service").innerHTML = "trurservcice";

        return server.getPrimaryService('00000000-0000-1000-8000-00805f9b34fb');
    }).then(service => {

        return Promise.all([
            service.getCharacteristic('00000002-0000-1000-8000-00805f9b34fb'),
            service.getCharacteristic('00000003-0000-1000-8000-00805f9b34fb').then(read)
        ]);

    }).catch(error => {
        document.getElementById("demo").innerHTML = "error" + error;
    });
}
```

-- 
GitHub Notification of comment by beaufortfrancois
Please view or discuss this issue at https://github.com/WebBluetoothCG/web-bluetooth/issues/370#issuecomment-316299073 using your GitHub account

Received on Wednesday, 19 July 2017 07:37:34 UTC