Need help in function format string

Hello there,

i'm very new to node-red.
I'm trying my first steps, but stuck now.

i made a bash script, querying blacklist from spamhaus
the output tells me, if there is an entry or not.

the function is as follows

var regExp = /.*payload/; // search for payload
var results = regExp.exec(msg.payload); // use as payload
msg.payload = results; // show result of payload

msg.payload without function
msg : Object

{ _msgid: "44ca6ba5.d46494", payload: "mailserver not listed by sbl…", rc: object }

msg payload with function:
function : (error)

"TypeError: Cannot read property '0' of null"

return msg;

aim should be a dashboard button, green if ok red if spam-listed

i hope someone could help me to solve, or give me a or some hints to my mistakes.

sry for my bad english

best regards e

In case you don't realise, the message is a javascript object, not a string. Have a read of the node red docs Working with Messages.

If you still can't get it going then tell us what, for the given message, you want the function to pass on? Also tell us the full contents of msg.payload going in.

If posting code again use the </> button and paste the function there, that stops the forum from messing with the format.

[Edit] Sorry, I should have said welcome to the forum @great12

Hello Colin,

thanks for your reply and hint, so i will walk through.
and thanks for the welcome

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