Hello I am new with node red. Currently, I am working with node-red and mysql database for my final year project. I would like to send temperature data to the database but i have error stated that the array is undefined.
if the data comes from different nodes, then you need to join the 2 bits of data together into 1 message/payload so that you can use them together in your insert query.
dont put the object in the payload array - only put the value.
e.g.
msg.payload = [ msg.payload.id ];
or if you have 2 params then update your query and add the 2 params (use debug window as instructed below)
const data = msg.payload;
msg.payload = [data.id, data.temperature];
msg.topic = "INSERT INTO temperature(`id`, `temperature`) VALUES (?,?)";
return msg;
↑ does that make sense?
There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.
Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.