Skip to content

Utils / Controller / evaluateNodeProperty

Function: evaluateNodeProperty()

ts
function evaluateNodeProperty(params): Promise<[Error | undefined, any]>;

Evaluates a node property in the Node-RED environment. This function wraps the evaluateNodeProperty utility from RED.util and returns a Promise. It resolves with a tuple containing an Error (if any) and the evaluation result.

The evaluation is performed asynchronously, and the function never rejects. The result will always be a tuple where:

  • The first element is an Error if one occurs during the evaluation, or undefined if no error occurs.
  • The second element is the result of the property evaluation, or undefined if no result is produced.

Note: This function is designed to be used in the context of Node-RED node development. It requires access to the RED object and the necessary node properties.

Parameters

ParameterTypeDescription

params

EvaluateNodePropertyParams

The parameters needed to evaluate the node property.

Returns

Promise<[Error | undefined, any]>

  • A promise that resolves with a tuple containing:
  • The error (if any) or undefined if no error occurs.
  • The result of the evaluation or undefined if no result is produced.

Examples

ts
// Example usage of evaluateNodeProperty with async/await
async function processNodeProperty() {
  const params: EvaluateNodePropertyParams = {
    value: "msg.payload",
    type: "jsonata",
    node: myNode,  // assuming myNode is a valid Node object
    msg: myMsg,    // assuming myMsg is a valid NodeMessage object
  };

  const [err, result] = await evaluateNodeProperty(params);

  if (err) {
    console.error("Error:", err);
  } else {
    console.log("Evaluation Result:", result);
  }
}
ts
// Handling the result when using the promise directly
evaluateNodeProperty({
  value: "msg.payload.someProperty",
  type: "str",
  node: myNode,  // assuming myNode is a valid Node object
  msg: myMsg,    // assuming myMsg is a valid NodeMessage object
})
.then(([err, result]) => {
  if (err) {
    console.error("Error:", err);
  } else {
    console.log("Result:", result);
  }
});

Version v1.33.1 - Built on 2026-03-28