Skip to content

Utils / Controller / getREDNode

Function: getREDNode()

ts
function getREDNode<TFields, TCreds>(idNode): Node<TCreds> & TFields | null;

Retrieves a node by its ID from the RED.nodes collection. This function returns the node object, which includes any custom fields and credentials associated with it. If the node with the specified ID doesn't exist, the function returns null.

Type Parameters

Type ParameterDefault typeDescription

TFields extends object

Record<any, any>

A generic type that extends an object, representing the additional fields associated with the node. This allows the caller to extend the node with custom fields.

TCreds extends object

Record<any, any>

A generic type that extends an object, representing the credentials associated with the node. This allows the caller to extend the node with custom credentials.

Parameters

ParameterTypeDescription

idNode

string

The unique identifier of the node to be retrieved.

Returns

Node<TCreds> & TFields | null

The node object with credentials and additional fields, or null if the node cannot be found.

Example

ts
// Example usage of the getREDNode function
const nodeId = 'node123';
const node = getREDNode<{customField: string}, {apiKey: string}>(nodeId);
if (node) {
  console.log(node.customField);  // Accessing custom field
  console.log(node.apiKey);       // Accessing node credentials
} else {
  console.log('Node not found');
}

// In this example:
// - We retrieve the node with ID 'node123'.
// - The node is expected to have a custom field called 'customField' and credentials including 'apiKey'.

Throws

Throws an error if the idNode is invalid or if there are issues retrieving the node.

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