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

Getting heart rate intraday time series for multiple days from server type OAuth application

Hi, I am trying to get heart rate intraday time series. I can get for one single day but I get 400 error for multiple days. My OAuth app is server type and I recently got approval from fitbit to request intraday heart rate. I wonder I have to make additional request to them or my way is wrong.

Below is the part of my code requesting the intraday heart rate time series.

 

 

 

var type = `/activities/heart/date/${date}/${date}/1sec/time/00:00/23:59.json`;
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://api.fitbit.com/1/user/' + userId + type);
//console.log("access " + access_token)
xhr.setRequestHeader("Authorization", 'Bearer ' + access_token);
xhr.send();
xhr.onreadystatechange = function(){
   if(this.readyState == 4 && this.status == 200){
     var data1 = JSON.parse(this.responseText);
     resolve(data1);
   } else if (this.status == 400){
     console.log("invalid refresh token")
   } else if (this.status == 401){
     console.log("access token expired")
   }
}

 

 

 

 
Best Answer
0 Votes
0 REPLIES 0