Let dweetio node send objects without alteration

This commit is contained in:
Dave Conway-Jones 2015-07-09 23:27:15 +01:00
parent 35eb6d71cd
commit 322c996064
2 changed files with 11 additions and 6 deletions

View File

@ -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."); }
});
}

View File

@ -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",