Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can i send HTTP request on clockface

I want to send a http request, but it returns "Unhandled ReferenceError: XMLHttpRequest is not defined".

this is my code:

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("GET", "requestUrl");
xhr.setRequestHeader("authorization", "Bearer {your_access_token}");

xhr.send(data);
console.log(this.responseText);

Best Answer
0 Votes
1 REPLY 1

The device itself doesn't have an Internet connection. You need to use fetch() within the companion app.

 

Something like this example app https://github.com/Fitbit/sdk-oauth

 

Best Answer
0 Votes