vendredi 27 avril 2018

Node-red:node-function - missing "null" value in if condition

I'm using Node-Red and in node function I have:

  ...  
  res = dataTransform.transform();  
  //critic case: res = [{"pressure":null}];  
  key = Object.keys(res[0]);  
  if(res[0][[key]]!=null)  
  {  
   ...   
   console.log("res:   ", [key]+":"+res[0][[key]]);  
  }  

on console.log I have always:

res: 0:[object Object]

And it enters in if-statement always (also when the "res[0][[key]]" is null).

What was I mistake?

Aucun commentaire:

Enregistrer un commentaire