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

I'm getting an error when I place activities within clock.ontick = (evt) {}

ANSWERED

I keep getting the following error:

 

Unhandled Exception: TypeError: Cannot read property 'adjusted' of undefined.

The steps aren't visible on the clock face either. 

I'm using the following code:

 

index.view:

<section x="85%" y="10%" width="80" height="20">
<image id="stepsIcon"/>
<text id="stepsLabel"/>
</section>

 

style.css

#stepsLabel {
font-size: 25;
font-family: System-Bold;
text-length: 32;
text-anchor: end;
x: -10;
fill: antiquewhite;
}

 

index.js

import { today } from "user-activity";

const stepsLabel = document.getElementById("stepsLabel");

 

clock.ontick = (evt) => {
if (appbit.permissions.granted("access_activity")) {
stepsLabel.text=`${today.adjusted.steps}`;
}
showDate(evt)
let today = evt.date;
let hours = today.getHours();
if (preferences.clockDisplay === "12h") {
// 12h format
hours = hours % 12 || 12;
} else {
// 24h format
hours = util.zeroPad(hours);
}
let mins = util.zeroPad(today.getMinutes());
myLabel.text = `${hours}:${mins}`;
}

 

I'm sure it's something simple I'm missing, I just can't seem to lock it in though.  Any help is highly appreciated.

 

Thanks in advance!

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

You're using the variable name 'today' for two different things.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
2 REPLIES 2

You're using the variable name 'today' for two different things.

Peter McLennan
Gondwana Software
Best Answer

I knew it was something simple.  Thank you so much for your help!

 

Best Answer