我是nodejs的新手,我只是想将event.js中的数据带到app.js,并将其放在同一个目录中,但我无法知道如何使其工作?
app.js
var SnmpData = require('./event.js');
console.log('SNMP data',SnmpData);
event.js
var message = {
event: {
header: {
eventSource: "d-sms"
},
body: {
data: [
{
oid: "1.3.6.1.4.140.625",
host: "135.89.157.201",
port: "162",
value: "Problem with monitoring device",
type: ""
},
{
oid: "1.3.6.1.4.345.765",
host: "135.89.157.299",
port: "162",
value: "Problem with monitoring device-2",
type: ""
}],
message: "Activate Collaborate"
}
}
}
}
答案 0 :(得分:1)
只需添加events.js
这个结尾:
exports.message = message ;
另请参阅节点模块以了解其工作原理。