I am trying to use world-clock npm module within function node for the first time.
So, I installed module first, added one to the settings.js:
functionGlobalContext: {
worldClock:require('world-clock'),
},
And here's my function:
const wClock=global.get('worldClock');
msg.payload=wClock.today('SYSTEM').toString();
return msg;
Which returns "TypeError: wClock.today is not a function"
typeof(wClock.today) returns the same, but typeof(wClock) returns "function".
What did I do wrong?
Colin
20 October 2020 06:31
2
If wClock
is a function then you cannot say wClock.property
, it must be wClock(something)`.
Absolutely. But I import the module. That's what makes it weird.
Here's an example from the world-clock npm node documentation:
const clock = require('world-clock')()
clock.today('SYSTEM').toString()
So it should work, but it doesn't
Colin
20 October 2020 06:51
5
Looking at the docs I think you want
wClock=global.get('worldClock')()
system
Closed
19 December 2020 06:54
7
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.