This is my app.js:
var express = require('express');
var app = express();
var router = express.Router();
var someroute = require('./someroute')(router);
app.use('/api/someroute', someroute );
app.listen(3000, function () {
console.log('Server listening on port 3000!')
});
This is my someroute.js:
module.exports = function(router) {
var security = require('../../lib/security');
router.post("/", function(req, res, next) {
console.log('THIS IS PRINTING');
security.security_function(function(err,result){
console.log('THIS IS NOT PRINTING');
});
});
//error handler
router.use(function(err, req, res, next) {
res.status(500).json(JSON.stringify({
error: err
}));
});
return router;
}
This is my security.js file:
exports.security_function= function() {
console.log("THIS IS NOT PRINTING EITHER");
});
When I call the /api/sameroute url it hits the route because I can see the first console.log being printed, but then when I expect the security_function to print something nothing is printed. Then the result this function brings back I also want it to print, but it is obviously not printing since the security_function didn't even seem to run.
via user2924127
No comments:
Post a Comment