mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Save point (#506)
This commit is contained in:
parent
b75f12aced
commit
d73d5f1af3
@ -66,15 +66,15 @@ module.exports = function(RED) {
|
|||||||
node.client.connect(function(sessionId) {
|
node.client.connect(function(sessionId) {
|
||||||
node.log('subscribing to: '+node.topic);
|
node.log('subscribing to: '+node.topic);
|
||||||
node.client.subscribe(node.topic, function(body, headers) {
|
node.client.subscribe(node.topic, function(body, headers) {
|
||||||
|
var newmsg={"headers":headers,"topic":node.topic}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
msg.payload = JSON.parse(body);
|
newmsg.payload = JSON.parse(body);
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
msg.payload = body;
|
newmsg.payload = body;
|
||||||
}
|
}
|
||||||
msg.headers = headers;
|
node.send(newmsg);
|
||||||
msg.topic = node.topic;
|
|
||||||
node.send(msg);
|
|
||||||
});
|
});
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
node.status({fill:"grey",shape:"dot",text:"error"});
|
node.status({fill:"grey",shape:"dot",text:"error"});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user