Node.warn help?

Why doesn't this work?

node.warn("Payload= ",msg.payload);

In this example msg.payload is a number from 1 to 7.

node.warn("Payload= " + msg.payload)

node.warn takes one parameter, you fed it two parameters

If payload is an object, it's better to do this...

node.warn(["payload", msg.payload]);


node.warn({"payload": msg.payload});

That way, you can expand the object and inspect it.


I can't mark two solutions, but you both nailed it for me.

I was confused because I misread my notes:
node.warn("variable= ", flow.variable);

It's an easy mistake to make - as good old console.log will take , between multiple parts.

... was just writing the exact same reply as Dave just posted, only to add... "we ought to look at making all of the log functions behave more like you'd expect.

the trickiness with that is that node.error does accept/expect a 2nd parameter...

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.