Possible Duplicate:
Call a “local” function within module.exports from another function in module.exports?
I am using node.js for develop my application. I have to call one method within another method from my main.js. how do i do this?
i am explaining detail here.
app.js
app.post('/getNotificationCount', function (req, res) {
res.setHeader('Cache-Control', 'max-age=0, must-revalidate, no-cache, no-store');
res.setHeader('Connection', 'keep-alive');
res.contentType('application/json');
res.setHeader('Expires', new Date().addYears(-10));
try {
//here i have my custom code/logic
//i have to call '/getNotification' method here, i have to pass parameter too..
}
catch (err) {
console.log('\r\n ' + new Date().toString() + ' - Try Catch from /getNotificationCount : ' + err + ' \r\n ');
res.json({ error: 'Forbidden' }, 403);
}
});
app.post('/getNotification', function (req, res) {
res.setHeader('Cache-Control', 'max-age=0, must-revalidate, no-cache, no-store');
res.setHeader('Connection', 'keep-alive');
res.contentType('application/json');
res.setHeader('Expires', new Date().addYears(-10));
try {
//my sql code goes here !!!
//I want retrieve parameter in req.body here...
}
catch (err) {
console.log('\r\n ' + new Date().toString() + ' - Try Catch from /getNotification : ' + err + ' \r\n ');
res.json({ error: 'Forbidden' }, 403);
}
});
How can i do this?