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 Answer
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.
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;
}
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.
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;
}