Store value in custom node HTML

I would like to store a certain dynamic value for it to be used in the HTML of my custom node.

For example, when using a spinner input we can create a function that is executed whenever the value of the spinner changes, like in this example which checks the value of the spinner is not below 1.
image

image

What Im trying to achieve: when an invalid value is inserted into the spinner I want the value to be replaced by the latest valid value. For example: First introduce valid value 5, then introduce invalid value "hi there", finally value is changed back to 5 since it is the latest valid value.

To accomplish this I was trying to store the previous valid value inside the defaults.
image

However, then I am unable to properly read those values with a console.log(), Ive tried the following:
image

I am unsure if a default has to necessarily bounded to an input or if it can be used to store data like Im trying to.
I also tried creating a hidden input with id 'node-input-previousOutputs' and using typedInput('hide') but I couldnt get that to work either.

Is my approach wrong? Is there a better way to do this?
Thanks in advance

It was much simpler than I thought, I was able to solve it with this, no hidden input.

Note that the '24' in the previousOutputs value does not do anything, it is the node.previousOutputs = node.outputs that matters.
Sorry for the trouble, hope this can help somebody in the future :smiley:

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