0

I am new to nodejs i just want to bring data from event.js to app.js its in same directory but i could not get it working any idea how to make it work ?

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"
        }
    }
}
}
hussain
  • 6,587
  • 18
  • 79
  • 152
  • 1
    Possible duplicate of [What is the purpose of Node.js module.exports and how do you use it?](http://stackoverflow.com/questions/5311334/what-is-the-purpose-of-node-js-module-exports-and-how-do-you-use-it) – Joe Clay Jun 03 '16 at 15:18

1 Answers1

1

just add in the end of events.js this :

exports.message = message ;

Also take a look to node modules to understand how things work.

Akram Saouri
  • 1,179
  • 8
  • 15