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

Batched heart rate

Hi,

 

I'm trying to improve my watch-face, however I'm not receiving any heartRate readings? This exported function is imported inside another file and then being called. Any help would be great!  

 

import { HeartRateSensor } from "heart-rate";
import document from 'document';

// Initialises the heart rate.
export default function outputHeartRate() {
  const hrm = new HeartRateSensor({ frequency: 1 });
  const heartEl = document.getElementById('heart');
  
  hrm.addEventListener("reading", () => {
    console.log(`Current heart rate: ${hrm.heartRate}`);
    heartEl.text = hrm.heartRate;
  });
  hrm.start();
}
Best Answer
0 Votes
2 REPLIES 2

Looks ok.

 

Did you request the access_heart_rate permission?

https://dev.fitbit.com/build/guides/permissions/

Best Answer
0 Votes

I've requested the heart rate permission via the package.json, I've got it working by moving the instantiating of the HeartRateSensor outside of the exported function. Do you know why that would make it work? Thanks!

Best Answer
0 Votes