Is there a way to read current node config data in RED.httpAdmin.get function?

Hi all,

I'm trying to expose a REST endpoint inside a node.
I would like to use a node config property inside of it (I don't want to fire the flow).

This is the code:

function MyNode(config) {
    RED.nodes.createNode(this, config);
    this.myproperty = config.myproperty;
    node.on('input', function (msg) {
    // ...
        node.send(msg);
    });
}

RED.nodes.registerType("myNode", MyNode);


RED.httpAdmin.get("/myendpoint", function (req, res) {
    // how to read node.myproperty?
});

To get a config property from settings.js, use RED.settings.<varname>.

You can't directly access a node instance property since your API is set up outside the registration function - as it should be. If you need a node instance property, add it as a request parameter to the API call. Just don't forget to sanitise any API parameters to prevent security issues.

Can you please share an example for the same

This is an old thread - you would be better off starting a new thread with some details about what you are trying to achieve.

This topic was automatically closed after 44 hours. New replies are no longer allowed.