// Get the price array from context
var priceArray = flow.get("pArray");
// Create an array of objects with time and price values
var records = [];
for (var i = 0; i < 24; i++) {
records.push({
"Time": new Date().toISOString().slice(0, 10) + "T" + i.toString().padStart(2, "0") + ":00:00",
"Price": Number(priceArray[i])
});
}
// Create the message payload
msg.payload = {
"records": records
};
return msg;