08-13-2021 14:21 - edited 08-13-2021 14:25
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

Recovery Runner
14
0
2
08-13-2021 14:21 - edited 08-13-2021 14:25
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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")
}
}

0 REPLIES 0
