Wrong use of variable in workflow function?

Hi,

I have this very, very simple javascript code in my workflow:

var now = get_ym_now();
var prev = get_ym_diff(now,-1);

'Now' has the value 202410 (Oct 2024).
The last lines of the function get_ym_now() are:
const ym = year*100 + month;
return ym;
So the return value is a number.

Typeof now returns this:
wf1

The function get_ym_diff calculates the year-month 1 month earlier: 202409.
When I use get_ym_diff(202410,-1), the result is 202409. Correct.
But when I use get_ym_diff(now,-1) it returns a null value.

Both functions are in the list of functions here:
wf2

Adding now = parseInt(now); didn't help.
What am I doing wrong here?

Problem solved.
I should use await like this:

var now = (await get_ym_now()).data;
var prev = (await get_ym_diff(now,-1)).data;

1 Like

Thanks for sharing your solution, @Reyer_Sneller!