sunnoy
30 December 2024 11:04
1
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:
RED.httpAdmin.post("/inject/:id", RED.auth.needsPermission("inject.write"), function(req,res) {
var node = RED.nodes.getNode(req.params.id);
if (node != null) {
try {
if (req.body && req.body.__user_inject_props__) {
node.receive(req.body);
} else {
node.receive();
}
res.sendStatus(200);
} catch(err) {
res.sendStatus(500);
node.error(RED._("inject.failed",{error:err.toString()}));
}
} else {
res.sendStatus(404);
}
});
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
sunnoy
31 December 2024 03:39
6
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.
system
Closed
1 March 2025 13:38
8
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.