k5map
1
I need a 2nd set of eyes because I'm at a loss to figure out this problem...
In a Function node, I am attempting to run this command:
msg.payload.lat = 30.05;
When I execute the flow, I get the error:
TypeError: Cannot set properties of undefined (setting 'lat')
Since both msg and payload are valid why am I not able to add a new object to msg.payload?
You are trying to set a lat
property on "something" - this "something" has a prerequisite: it has to be an object before you can assign a property.
msg.payload = 'blabla'
< not an object
msg.payload.lat = 30.50
= error.
msg.payload = {}
< is an object
msg.payload.lat = 30.50
= ok
k5map
3
Forgot to include that this is the first line in my Function:
msg.payload = {};
Post your complete function as we can only guess what is happening.
k5map
5
Here is a copy of my code:
msg.payload = {};
msg.payload.name = "K5WH-117";
msg.paylaod.lat = 30.05;
msg.payload.lon = -95.53;
return msg;
k5map
7
(wiping the egg from my face)... well SON OF A ... this is why I needed a 2nd set of eyes. Thank You!
3 Likes
system
Closed
8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.