03-12-2018 19:14
03-12-2018 19:14
I'm trying to request the user's heart rate zone using HeartRateZone(). As far as I understand it's done by using this code:
console.log(user.heartRateZone(hrm.heartRate));
I'm getting this error though:
Unhandled TypeError: Argument at index 0 is not a Number
Any help would be appreciated, thanks!
Answered! Go to the Best Answer.
Best Answer03-19-2018 23:16
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
03-19-2018 23:16
Try this, sorry it's untested.
import { HeartRateSensor } from "heart-rate";
import { user } from "user-profile";
let lastReading = 0;
let hrm = new HeartRateSensor();
hrm.start();
hrm.onreading = function() {
if (hrm.timestamp === lastReading) {
console.log("Off wrist?");
} else {
console.log("Heart rate: " + hrm.heartRate);
console.log("Zone: " + user.heartRateZone(hrm.heartRate));
}
lastReading = hrm.timestamp;
}
03-19-2018 23:16
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
03-19-2018 23:16
Try this, sorry it's untested.
import { HeartRateSensor } from "heart-rate";
import { user } from "user-profile";
let lastReading = 0;
let hrm = new HeartRateSensor();
hrm.start();
hrm.onreading = function() {
if (hrm.timestamp === lastReading) {
console.log("Off wrist?");
} else {
console.log("Heart rate: " + hrm.heartRate);
console.log("Zone: " + user.heartRateZone(hrm.heartRate));
}
lastReading = hrm.timestamp;
}