Trying to output log/errors to table in web ui

I'm trying to output the node red logs into a table for easy debuging on my phone.... The problem is str needs to be a string of json, not the type [object Object] which it keeps giving me. Ive tried converting to string multiple ways with no luck.

I have the following function:

let logs = flow.get('logs') || []

var str = msg.payload.message

// prepare the row (keep other columns as-is)
let row = [
    //msg.payload.time || '',
    //msg.payload.type || '',
    msg.payload.source,
    str,
]

// debug: this needs to print a string! but it returns an object
node.error(str)

logs.push(row)

// cap at 20 rows
if (logs.length > 20) logs.shift()
flow.set('logs', logs)

msg.payload = logs
return msg

Pass the output of your function through a JSON node

Alternatively...

msg.payload = JSON.stringify(logs)

Unfortunately for both, that converts the string to "[object Object]" instead of the contents of the object.

How are you trying to display it? Are you using UIBUILDER, Dashboard 2 or Dashboard 1?

I'm using dashboard 2 with a table widget. Also output node.error displays the same format.

Where does msg.payload.message come from? How is it constructed?

I'm using a catch node to catch errors. Passing them to this function. Then this function outputs to a table node.

Catch - function - table

Cheers

If you connect a debug node to the catch, showing the complete message object, what does it contain?

It contains the following object:

{"battery":100,"device":{"applicationVersion":147,"dateCode":"22092025","friendlyName":"Front Motion","hardwareVersion":1,"ieeeAddr":"0xa4c1386709fdfac3","manufacturerID":4742,"manufacturerName":"_TZE200_rhgsbacq","model":"ZG-204ZV","networkAddress":43435,"powerSource":"Battery","softwareBuildID":"0122092025","stackVersion":2,"type":"EndDevice","zclVersion":3},"fading_time":30,"humidity":70,"humidity_calibration":0,"illuminance":745,"illuminance_interval":1,"indicator":"OFF","linkquality":51,"motion_detection_sensitivity":2,"presence":false,"temperature":17.8,"temperature_calibration":0,"temperature_unit":"celsius"}

That data does not include a msg.payload, so no msg.payload.message.

Indeed, it can't be that you only shared the payload: no msg.message either

What contains that object? Did you set the debug node to Output Complete Message as requested?

argh so silly! that was it.... msg.payload instead of msg.payload.message

Thanks guys