08-25-2019 04:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-25-2019 04:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
While I am able to create events inside index.js of the companion, I am not able to do so within index.js of the app itself. What am I missing?
index.js:
console.log('Up and running.'); var event = new Event('test'); console.log('Event added.')
console output:
[1:45:51 PM] App: App Closed [1:45:51 PM] App: App Started [1:45:51 PM] App: Up and running. (app/index.js:1,1) [1:45:51 PM] App: Unhandled exception: ReferenceError: Event is not defined event at app/index.js:3,1 [1:45:52 PM] Companion: Up and running. (companion/index.js:1,1) [1:45:52 PM] Companion: Event added. (companion/index.js:5,1)
I am using the following versions of the sdk:
08-25-2019 13:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


08-25-2019 13:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Two probably-wrong guesses:
- You may not be importing the right file. (It isn't clear from the documentation what the right file is, if any.)
- The device runs an older version of javascript, so some things that work on the companion don't work on the watch.
Gondwana Software

08-26-2019 10:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-26-2019 10:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Gondwana wrote:You may not be importing the right file.
There's no need to import anything inside index.js of the companion to make use of the Event class there, so I'd doubt that.
@Gondwana wrote:The device runs an older version of javascript, so some things that work on the companion don't work on the watch.
I guess so, too. On a different thread I recently read about restricted capabilities of the device regarding date methods like "toLocaleString()". JonFitbit stated the following cause there: "The JavaScript on the device only supports ES5.1, ..." Gonna stick to callbacks then, I'm afraid... /:

03-16-2020 11:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-16-2020 11:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Try this:

