I am using express and node js for my app
my main index.js file is
var express = require("express");
var app = module.exports = express();
var bodyParser = require('body-parser');
var MongoClient = require('mongodb').MongoClient
, assert = require('assert');
var myProject= require("services");
app.use(myProject.callService());
and my services.js file is
var res = module.exports;
res.callService = function () {
console.log('here ===')
}
but when I am trying to call this callService function from index.js I am getting an error
app.use() requires middleware functions
can you please tell what I am doing wrong here.
undefined
(which is whatmyProject.callService()
returns) isn't valid middleware. – Kevin Bnext()
or finish the request itself so even if you had passed the middleware function reference correctly, what you have still wouldn't work. – jfriend00