It depends exactly what no payload looks like. It could be that msg.payload exists, but has a null value... in which case:
if (msg.payload === null)
Or if there is no payload property at all...
if (!msg.hasOwnProperty('payload'))
Nick
I have a function node that is being triggered each second it sends the time to return [msg1,....;--In the same function I want to process a message.payload that only comes into the function node occasionallyBut how to identify when there is a msg.payload because when there is no payload I get unidentified, I need something likeif(there is a msg.payload){var parts = msg.payload.split(",");etcmsg1.payload = whatever}else{var d = new Date();etcmsg1.payload = (h+":"+m+":"+s);return [msg1, ..........
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.
It isn't currently possible, but as you said, something we've got on the list for a future release.
Nick
--
I am now on my next task and scratching my head again...
// initialise the variable if it doesn't exist alreadycontext.set('tick',context.get('tick')||0);var target = 10;
msg.payload = context.get('tick'); node.send(msg);
node.status({ fill : "yellow", shape : "ring", text : "Counter: "+context.get('tick')+" Target: "+target});
context.set('tick',context.get('tick')+1);
if( context.get('tick') > target) { context.set('tick',0);}