0
我已经加入请求模块和由在主settings.js变化每文档中的功能的节点:无法从请求包访问get方法在
// Anything in this hash is globally available to all functions.
// It is accessed as context.global.
// eg:
// functionGlobalContext: { os:require('os') }
// can be accessed in a function block as:
// context.global.os
functionGlobalContext: {
requestModule:require('request').defaults({jar: true})
// os:require('os'),
// octalbonescript:require('octalbonescript'),
// jfive:require("johnny-five"),
// j5board:require("johnny-five").Board({repl:false})
},
这是代码在我的功能节点中的一个:
var request = context.global.requestModule;
request.get('http://192.168.0.44:3000' + '/api/stats',
function (err, data) {
if (err) {
console.log("could not process data");
}
else {
var body = JSON.parse(data.body);
msg.payload = body.deviceCount;
}
});
return msg;
我的节点红色版本(0.16.2)
为什么你需要使用请求模块呢? http请求节点将正常工作 – hardillb
我需要对每个数据访问请求进行一些额外的身份验证过程,该请求在默认的http请求节点中不存在 –