node-red-contrib-cognitive-services
Advanced tools
Comparing version 0.0.1 to 0.0.2
var request = require('request'); | ||
module.exports = function(RED) { | ||
function weblm(config) { | ||
module.exports = function(RED) | ||
{ | ||
function weblm(config) | ||
{ | ||
RED.nodes.createNode(this,config); | ||
var node = this; | ||
this.on('input', function(msg) { | ||
this.on('input', function(msg) | ||
{ | ||
console.log("config.operation=" + config.operation); | ||
@@ -30,9 +33,21 @@ if (this.credentials == null || this.credentials.key == null || this.credentials.key == "") | ||
{ | ||
try { | ||
console.log("body=" + body); | ||
if (body.results != null && body.results.length > 0) | ||
try | ||
{ | ||
if (!error) | ||
{ | ||
msg.payload = body.results[0].probability; | ||
node.send(msg); | ||
console.log("response.statusCode=" + response.statusCode + ", body=" + body); | ||
if (response.statusCode == 200 && body.results != null && body.results.length > 0) | ||
{ | ||
msg.payload = body.results[0].probability; | ||
node.send(msg); | ||
} | ||
else | ||
{ | ||
node.error(body); | ||
} | ||
} | ||
else | ||
{ | ||
node.error(error); | ||
} | ||
} | ||
@@ -58,6 +73,21 @@ catch (e) | ||
{ | ||
try { | ||
console.log("body=" + body); | ||
msg.payload = body; | ||
node.send(msg); | ||
try | ||
{ | ||
if (!error) | ||
{ | ||
console.log("response.statusCode=" + response.statusCode + ", body=" + body); | ||
if (response.statusCode == 200) | ||
{ | ||
msg.payload = body; | ||
node.send(msg); | ||
} | ||
else | ||
{ | ||
node.error(body); | ||
} | ||
} | ||
else | ||
{ | ||
node.error(error); | ||
} | ||
} | ||
@@ -64,0 +94,0 @@ catch (e) |
{ | ||
"name" : "node-red-contrib-cognitive-services", | ||
"version" : "0.0.1", | ||
"version" : "0.0.2", | ||
"description" : "Microsoft Cognitive Services", | ||
@@ -13,2 +13,2 @@ "dependencies": { | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
40764
16
170