I want to schedule a simple task using Agenda with nodejs, however it is not executing when it is wrapped in apiRoutes (express router)
var apiRoutes = express.Router();
app.use('/api', apiRoutes);
apiRoutes.post('/scheduler/submit', function (req, res) {
agenda.define('test', function () {
console.log('Test');
});
agenda.on('ready', function () {
agenda.every('*/1 * * * *', 'test');
agenda.start();
});
});
but if i place that code outside, it works however. Hmm, any idea?
var apiRoutes = express.Router();
app.use('/api', apiRoutes);
agenda.define('test', function () {
console.log('Test');
});
agenda.on('ready', function () {
agenda.every('*/1 * * * *', 'test');
agenda.start();
});
apiRoutes.post('/scheduler/submit', function (req, res) {
// Leave blank
});