09-30-2020 20:03
09-30-2020 20:03
Hello,
I'm having trouble displaying activeZoneMinutes on a clock face I'm designing and could use some help. I keep getting the [object Object] error. I have no trouble displaying everything else: heartRateSensor, steps, distance, etc... I'm fairly new to javascript and very new to fitbit clock faces. Any help would be much appreciated. I'm using the following code:
index.view
<section x="10%" y="40%" width="80" height="20">
<image id="activeIcon"/>
<text id="activeLabel"/>
</section>
style.css
#activeLabel {
font-size: 25;
font-family: System-Bold;
text-length: 32;
text-anchor: start;
x: 30;
fill: white;
}
#activeIcon {
width: 25;
height: 25;
href: "stat_am_open_32px.png";
fill: white;
}
index.js
import { me as appbit } from "appbit";
import { today } from "user-activity";
const activeLabel = document.getElementById("activeLabel");
if (appbit.permissions.granted("access_activity")) {
console.log(`${today.adjusted.steps} Steps`);
stepsLabel.text=`${today.adjusted.steps}`;
console.log(`${today.adjusted.distance} Distance`);
distanceLabel.text=`${today.adjusted.distance}`;
console.log(`${today.adjusted.elevationGain} Floors`);
floorsLabel.text=`${today.adjusted.elevationGain}`;
if (today.local.activeZoneMinutes !== undefined) {
console.log(`${today.adjusted.activeZoneMinutes} Active Minutes`);
activeLabel.text=`${today.adjusted.activeZoneMinutes}`;
}
if (today.local.calories !== undefined) {
caloriesLabel.text=`${today.adjusted.calories}`;
console.log(`${today.adjusted.calories} calories`);
}
}
Thanks in advance!!!
Answered! Go to the Best Answer.
09-30-2020 20:08
09-30-2020 20:08
activeZoneMinutes isn't just one number. You need to break into the object to get what you want (which is probably .total). Details: https://dev.fitbit.com/blog/2020-09-10-announcing-fitbit-os-sdk-4.2/#user-activity-api-active-zone-m...
09-30-2020 20:08
09-30-2020 20:08
activeZoneMinutes isn't just one number. You need to break into the object to get what you want (which is probably .total). Details: https://dev.fitbit.com/blog/2020-09-10-announcing-fitbit-os-sdk-4.2/#user-activity-api-active-zone-m...
09-30-2020 20:33
09-30-2020 20:33
Thank you so much!!! Problem solved.