I'm just learning this stuff as I go. I am parsing data returned by a HTTP GET input node and pub'ing each item's value to my mqtt server (thanks to bakman2)
//obj = [{"macAddress":"XX:XX:XX:XX:XX:XX","lastData":{"dateutc":1563819660000,"winddir":206,"windspeedmph":0.45,"windgustmph":1.12,"maxdailygust":9.17,"tempf":81.3,"battout":1,"humidity":43,"hourlyrainin":0,"eventrainin":0,"dailyrainin":0,"weeklyrainin":0,"monthlyrainin":0.12,"yearlyrainin":0.12,"totalrainin":0.12,"tempinf":73,"battin":1,"humidityin":52,"baromrelin":29.37,"baromabsin":29.31,"uv":7,"solarradiation":750.41,"temp1f":69.26,"humidity1":58,"batt1":1,"feelsLike":81.2,"dewPoint":56.64,"lastRain":"2019-07-17T20:16:00.000Z","tz":"America/Chicago","date":"2019-07-22T18:21:00.000Z"},"info":{"name":"Name1","location":""}},{"macAddress":"XX:XX:XX:XX:XX:XX","lastData":{"dateutc":1563819660000,"winddir":266,"windspeedmph":3.36,"windgustmph":4.47,"maxdailygust":10.29,"tempf":77.5,"battout":1,"humidity":47,"hourlyrainin":0,"eventrainin":0,"dailyrainin":0,"weeklyrainin":0,"monthlyrainin":0.02,"yearlyrainin":0.02,"totalrainin":0.02,"uv":7,"solarradiation":789.92,"feelsLike":77.16,"dewPoint":55.66,"lastRain":"2019-07-19T01:07:00.000Z","tz":"America/Chicago","date":"2019-07-22T18:21:00.000Z"},"info":{"location":"","name":"Name2"}}]
for (let item in msg.payload){
for (let key of Object.keys(msg.payload[item].lastData)){
t = 'weather/' + msg.payload[item].info.name.toLowerCase() + "/" + key
v = msg.payload[item].lastData[key]
node.send({topic:t, payload:v})
}
}
Periodically I get an error in my debug view from the function node.
TypeError: Cannot convert undefined or null to object
How can/should I go about catching and analyzing these errors?