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,12 +25,18 @@ module.exports = function(RED) {
|
||||
if (dweetio == null) { dweetio = new DweetClient(); }
|
||||
var node = this;
|
||||
|
||||
var isObject = function(a) {
|
||||
return (!!a) && (a.constructor === Object);
|
||||
};
|
||||
|
||||
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;
|
||||
try {
|
||||
dweetio.dweet_for(thing, {payload:msg.payload}, function(err, dweet) {
|
||||
//console.log(dweet.thing); // "my-thing"
|
||||
dweetio.dweet_for(thing, msg.payload, function(err, dweet) {
|
||||
//console.log(dweet.thing); // "my-thing"
|
||||
//console.log(dweet.content); // The content of the dweet
|
||||
//console.log(dweet.created); // The create date of the dweet
|
||||
});
|
||||
@ -38,7 +44,6 @@ module.exports = function(RED) {
|
||||
catch (err) {
|
||||
node.log(err);
|
||||
}
|
||||
//} else { node.warn("Dweetio only sends payload objects."); }
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name" : "node-red-node-dweetio",
|
||||
"version" : "0.0.5",
|
||||
"version" : "0.0.4",
|
||||
"description" : "A Node-RED node to send and receive simple dweets",
|
||||
"dependencies" : {
|
||||
"node-dweetio" : "0.0.11"
|
||||
"node-dweetio" : "0.0.12"
|
||||
},
|
||||
"repository" : {
|
||||
"type":"git",
|
||||
|
Loading…
Reference in New Issue
Block a user