I am trying to pass function response from one Node.js script to another
Here is what I am trying. Index.js
var express = require('express');
require('./meter');
var app = express();
app.get('/',function(req,res){
return; //hi function from another file
})
app.listen(3000);
console.log('listening on 3000 port')
meter.js
module.exports = {
hi: function(req, res) {
return res.status(200).json({"message" : "Hello V1"});
}
};
does require function only will do the job?
Thanks in advance.
hiinmeter.jsand you'll have to use it similar to what you've done for express.