I have this simple function to read the specific lines of my interest in a message and assign the topic.
msg.payload = msg.payload.commonAnnotations.description;
msg.topic = msg.payload.commonAnnotations.summary;
return msg
I have copied both paths from the debug window.
The msg.topic is giving error
"TypeError: Cannot read properties of undefined (reading 'summary')"
I don't understand why and how to resolve this.
The msg.payload it is fine. I can get it without errors.
jbudd
2
Your first line replaces msg.payload.
Therefore msg.payload.commonAnnotations.summary no longer exists.
Set msg.topic first.
Colin
3
You can avoid that by using something like
let annotations = msg.payload.commonAnnotations
msg.payload = annotations.description;
msg.topic = annotations.summary;
return msg
1 Like
system
Closed
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.