Hi,
I’m trying to pass a number to a function node (inside the array):
The final message I’m getting is “Hola. La temperatura es de [object Objetc] grados”, instead of “Hola. La temperatura es de 22 grados”.
What am I doing wrong? Thanks!
Hi,
I’m trying to pass a number to a function node (inside the array):
The final message I’m getting is “Hola. La temperatura es de [object Objetc] grados”, instead of “Hola. La temperatura es de 22 grados”.
What am I doing wrong? Thanks!
You’re overriding msg.payload
on line 1 with an empty object then referencing that object on line 7 and 8.
const myArray = [
`Hace ${msg.payload} grados`,
`Hola. La temperatura es de ${msg.payload} grados`
];
const randomItem = myArray[Math.floor(Math.random()*myArray.length)];
msg.payload = { data: { message: randomItem } };
return msg;
Great fix! Thanks a million!