When using a Function Node, how do I test for the following to be null. It’s the else if line. With OwnTracks, it sends home via msg.payload.inregions[0] but what if that msg type doesnt exist.
if (msg.payload._type == "location"){
if (msg.payload.inregions[0] == "home"){
return {"topic": "OwnTracks", "payload": "home"}
}
else if (msg.payload.inregions[0] == null){
return {"topic": "OwnTracks", "payload": "away"}
}
else {
return {"topic": "OwnTracks", "payload": "away"}
}
}