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

Can't find out what's wrong

ANSWERED

I'm coding a clock face app. Here's the code:

import clock from "clock";
import document from "document";
import { preferences } from "user-settings";
import * as util from "../common/utils";
import { today } from "user-activity";
import { HeartRateSensor } from "heart-rate";
let heartRate = document.getElementById("heartRate");
heartRate.text = "-";
var hrm = new HeartRateSensor();
hrm.onreading = function() {
// Peek the current sensor values
heartRate.text = hrm.heartRate;
console.log("Current heart rate: " + hrm.heartRate);
hrm.stop()
hrm.start()
// Update the clock every minute
clock.granularity = "seconds";

let txtSteps = document.getElementById("txtSteps");

// inside the clock tick handler
txtSteps.text = today.adjusted.steps || 5;


// Get a handle on the <text> element
const myLabel = document.getElementById("myLabel");

// Update the <text> element every tick with the current time
clock.ontick = (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}`;
}

It comes out with this:

  • TS1005: '}' expected.
  • Error: Failed to compile /project/app/index.js
    • Details: id: /project/app/index.js hook: transform code: PLUGIN_ERROR

I have a } at the end, like it wants me to have.

I'm new to this, please help!

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

For the heart rate sensor, you have the function on reading hrm with an open bracket - 

 


@FunGamer wrote:

var hrm = new HeartRateSensor();
hrm.onreading = function() {

 


but haven't given the closing brackets } for this function. 

View best answer in original post

Best Answer
0 Votes
3 REPLIES 3

The SDK Developer Board is a place to more likely get help with this.

Before posting, re-read to see if it would make sense to someone else not looking at your Fitbit or phone.

Best Answer
0 Votes

For the heart rate sensor, you have the function on reading hrm with an open bracket - 

 


@FunGamer wrote:

var hrm = new HeartRateSensor();
hrm.onreading = function() {

 


but haven't given the closing brackets } for this function. 

Best Answer
0 Votes

Oh, I did not look through the code lol, thanks for that!

Best Answer
0 Votes