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

App: Unhandled exception: TypeError: Cannot read property 'getElementById' of undefined

I'm moving a clockface I developed in Studio into a local node.js project.

I'm getting the following error:

 

 

App: Unhandled exception: TypeError: Expected a function.
  ? at app/index.js:14,7

 

 

`document` is clearly defined, so I'm baffled by this.

I tried the basic Fitbit example at https://dev.fitbit.com/getting-started/ and it has the same issue. This is a Versa 2 project using SDK ~4.3.0 with "mira" as the target.

 

 

import clock from "clock";
import * as document from "document";
import { preferences } from "user-settings";
import * as util from "../resources/utils";
import { HeartRateSensor } from "heart-rate";
import { me as appbit } from "appbit";
import { today as toDay } from "user-activity";
import { battery } from "power";

// update the clock every minute
clock.granularity = "minutes";

// THE PROBLEM IS HERE
const theTime = document.getElementById("theTime");

 

 

 

 

 

Best Answer
0 Votes
3 REPLIES 3

This is a long-shot, but just try:

import document from 'document'

 

Peter McLennan
Gondwana Software
Best Answer

That was my theory; I didn't want to lead with it in case I was mistaken!

Peter McLennan
Gondwana Software
Best Answer