I'm using some javascript in a function node, but when I deploy it, I get a red triangle on the node, and a pop-up saying The workspace contains some nodes that are not properly configured:
and options
is highlighted from this line;
const parts = new Intl.DateTimeFormat('en-GB', options).formatToParts(now);
The javascript runs ok, and does what it's supposed to do, but it's a pain having to acknowledge the popup every time I deploy.
Is there a problem with the code?
// Get or initialize chart data
let chartData1 = flow.get("chartData1") || {
x: [],
y: []
};
// Handle flush request
if (msg.topic === "flush") {
msg.payload = [{
x: chartData1.x,
y: chartData1.y,
type: "line"
}];
return msg;
}
// Validate input
if (!msg.payload || typeof msg.payload.grid !== "number") {
return null; // drop if invalid
}
// Normal update: append new point
const now = new Date();
const options = {
timeZone: 'Europe/London',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hourCycle: 'h23' // use 24-hour format
};
const parts = new Intl.DateTimeFormat('en-GB', options).formatToParts(now);
const obj = Object.fromEntries(parts.map(p => [p.type, p.value]));
const time = `${obj.year}-${obj.month}-${obj.day} ${obj.hour}:${obj.minute}:${obj.second}`;
const value = msg.payload.grid;
chartData1.x.push(time);
chartData1.y.push(value);
// Limit size to 30 minutes
if (chartData1.x.length > 360) {
chartData1.x.shift();
chartData1.y.shift();
}
node.status("No of data points = " + chartData1.x.length);
// Save updated context
flow.set("chartData1", chartData1);
// Return just the latest point
msg.payload = [{
x: [time],
y: [value],
type: "line"
}];
return msg;