Button send msg not working

k8s-docker-ops.html

button: {
            onclick: function() {
        
                
                $.ajax({
                    url: "inject/" + this.id,
                    method: "POST",
                    data: JSON.stringify({
                        msg: {
                            operation: ""
                        }
                    }),
                    contentType: "application/json",
                    success: function(resp) {
                        RED.notify("ok", "success");
                    }
                });
            }
        },



        node.on('input', async function(msg) {
            const operation = msg.operation || '';
            const params = msg.params || {};
       **k8s-docker-ops.js**
            node.log(`Received operation: ${operation}`);
            node.log(`Parameters: ${JSON.stringify(params)}`);
            node.log(`msg: ${JSON.stringify(msg)}`);

log

30 Dec 18:52:59 - [info] [k8s-docker-ops:4e2ca4f113aeebd7] Received operation: 
30 Dec 18:52:59 - [info] [k8s-docker-ops:4e2ca4f113aeebd7] Parameters: {}
30 Dec 18:52:59 - [info] [k8s-docker-ops:4e2ca4f113aeebd7] msg: {"_msgid":"e42659bd820a79de"}

Welcome to the forums @sunnoy

Sorry, but I don't recommend you hi-jack core node internals.

The endpoint inject/{id} is only for the inject node - so if the fundamentals change with it -your node will break.

Instead, create your own endpoint, and handle it internally in your own node

Marcus will develop the answer for you, here is the missing code:

1 Like

Use the above as an example (inject node internals)....

BUT for the love of god - dont use /inject - use something unique to your node.
anyone installing your Node will be very unhappy, if you break core nodes

The reason you are not getting data - is that you are trying to hijack the inject node - and it some has checks in place (I believe)

Develop your own, and you should get further

1 Like

tks i have done this

But how do I find the relevant API references, for example RED.httpAdmin.post in the documentation Node-RED not in detail

Perhaps you are going off-piste somewhat?

Please back up for a second and describe what you are trying to do with your node so that we can help you understand the best way to approach things.

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