I send a payload (number) and the node spits out that many messages.
(Contents not important)
So for now this is the code:
let x = msg.payload;
let y = 0;
context.set("COUNT",x); // Not really needed?
while (y < x)
{
y = y + 1;
node.warn(y);
// node.send(y); // Not sure on structure. But.....
delay(1000);
}
But when I inject a value, I get this as an error:
TypeError: Cannot read property 'startsWith' of undefined
I've seen this before, but can't remember where and why.
Putting that aside, what am I missing on the loop?
Delay as such is not available in javascript. You have to use setTimeout in some way. You could eventually write a function with the name 'delay' but inside, you have to use setTimeout