# Can a custom node have a function as a property?

**URL:** <https://discourse.nodered.org/t/can-a-custom-node-have-a-function-as-a-property/81888>\
**Category:** Developing Nodes\
**Created:** [9 October 2023 15:53 UTC](https://discourse.nodered.org/t/can-a-custom-node-have-a-function-as-a-property/81888 "2023-10-09T15:53:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsv](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@nsv](https://discourse.nodered.org/u/nsv)\
**Post date:** [9 October 2023 15:53 UTC](https://discourse.nodered.org/t/can-a-custom-node-have-a-function-as-a-property/81888/1 "2023-10-09T15:53:19Z")

</div>

Context:

I have a custom node currently in use that allows for a selection to be made in the config panel via drop down which is a dynamic list of end points. Current behavior is on selection, the endpoint is accessed and the data is parsed and saved to a static property value of the node/config for use downstream.

The Problem:

If the endpoint has had a data change, our saved value in node/config is no longer reflective of the actual endpoint data.

The Desire:

I would like to maintain compatibility with the property name in use, but instead of the property supplying the saved static value, I would like the property to call a function to retrieve/parse/return the data to the caller without introducing a breaking change for current users of the node ideally.

I've tried:

1. defining a function as the value for the relevant key in defaults
2. removing the key from defaults, defining the function outside of defaults

Neither has worked.

Is it possible to define a property as a function for a custom node in node-red ?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [9 October 2023 16:37 UTC](https://discourse.nodered.org/t/can-a-custom-node-have-a-function-as-a-property/81888/2 "2023-10-09T16:37:53Z")

</div>

If the endpoint has updated data, how do you expect to know? Is it that you want your node to query the endpoint every time it receives a msg input?

If so, you don't need to save anything in the Editor, you need to call the endpoint from the runtime instead .

If not, what triggers a new fetch of the data?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 December 2023 16:38 UTC](https://discourse.nodered.org/t/can-a-custom-node-have-a-function-as-a-property/81888/3 "2023-12-08T16:38:11Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
