Hi,
I try to use await delay(1000) into this function
const delay = ms => new Promise(res => context.set("timer", setTimeout(res, ms)));
//x is an array
const x = msg.payload;
x.forEach(element => {
const valore = (element.value)
const id = (element.id)
msg.topic = "UPDATE Variables SET Valore = '" + valore + "' WHERE Id = " + id
msg.pass = 2
node.status(valore + " " + id)
node.send(msg)
await delay(1000);
}
);
Have you tried the "quick fix" (hint, the arrow function must be async - just like the tip says)
That said...
This is NOT the node-red / low-code way. Get rid of the async await & simply send all your messages out of the function without delay then pass the msg through a delay node set to rate limit 1 msg per sec.