What is the HeartRate module used for FitBit?

165 Views Asked by At

I'm trying to make an application for FitBit without using the companion app that will allow me to get the accelerometer data and heart rate.

The Heart Rate Sensor Guide of FitBit gives the following code, but does not exactly specify what the imported module is, except that it is the "HeartRate module":

// Import the HeartRate module
import { HeartRateSensor } from "heart-rate";

// Create a new instance of the HeartRateSensor object
var hrm = new HeartRateSensor();

hrm.onreading = function() {

  // Peek the current sensor values
  console.log("Current heart rate: " + hrm.heartRate);

  // Stop monitoring the sensor
  hrm.stop();
}

// Begin monitoring the sensor
hrm.start();

The example that FitBit has on GitHub, also implements the code in a similar fashion, with the module being nowhere to be found.

When I attempted to run the code on Sublime Text, it gave the error "SyntaxError: Unexpected token import"

What can I do to get the heart rate data?

1

There are 1 best solutions below

0
On

For import to work, you need @std/esm package.