mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Let dweetio node send objects without alteration
This commit is contained in:
parent
35eb6d71cd
commit
322c996064
@ -25,11 +25,17 @@ module.exports = function(RED) {
|
|||||||
if (dweetio == null) { dweetio = new DweetClient(); }
|
if (dweetio == null) { dweetio = new DweetClient(); }
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
|
var isObject = function(a) {
|
||||||
|
return (!!a) && (a.constructor === Object);
|
||||||
|
};
|
||||||
|
|
||||||
this.on("input",function(msg) {
|
this.on("input",function(msg) {
|
||||||
//if (typeof(msg.payload) === 'object') {
|
if (!isObject(msg.payload)) {
|
||||||
|
msg.payload = {payload:msg.payload};
|
||||||
|
}
|
||||||
var thing = node.thing || msg.thing;
|
var thing = node.thing || msg.thing;
|
||||||
try {
|
try {
|
||||||
dweetio.dweet_for(thing, {payload:msg.payload}, function(err, dweet) {
|
dweetio.dweet_for(thing, msg.payload, function(err, dweet) {
|
||||||
//console.log(dweet.thing); // "my-thing"
|
//console.log(dweet.thing); // "my-thing"
|
||||||
//console.log(dweet.content); // The content of the dweet
|
//console.log(dweet.content); // The content of the dweet
|
||||||
//console.log(dweet.created); // The create date of the dweet
|
//console.log(dweet.created); // The create date of the dweet
|
||||||
@ -38,7 +44,6 @@ module.exports = function(RED) {
|
|||||||
catch (err) {
|
catch (err) {
|
||||||
node.log(err);
|
node.log(err);
|
||||||
}
|
}
|
||||||
//} else { node.warn("Dweetio only sends payload objects."); }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-dweetio",
|
"name" : "node-red-node-dweetio",
|
||||||
"version" : "0.0.5",
|
"version" : "0.0.4",
|
||||||
"description" : "A Node-RED node to send and receive simple dweets",
|
"description" : "A Node-RED node to send and receive simple dweets",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"node-dweetio" : "0.0.11"
|
"node-dweetio" : "0.0.12"
|
||||||
},
|
},
|
||||||
"repository" : {
|
"repository" : {
|
||||||
"type":"git",
|
"type":"git",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user