I am working with mongoose.
I wrote the following code in routes.js
var docs = require('../app/controllers/genericController');
app.post('/newdoc', docs.createMainDoc);
app.get('/listdoc', docs.listDocs);
and in genericController :
exports.listDoc = function(req, res) {
var Model = mongoose.model(req.model); //i dont know, if this is defined or undefined. Actually i am not able to check it. Even if i comment whole body of this exports.listDoc, then also i get the same error. just assume here that here i am getting model.
Model.find(function(err, models) {
if (err) {
res.render('error', {
status: 500
});
} else {
res.jsonp(models);
}
});
};
Bu i am getting error :
.get() requires callback functions but got a [object Undefined]
How to resolve it?
You have docs.listDocs
instead of docs.listDoc
. That's why it's undefined
.
app.get('/listdoc', docs.listDoc/*s*/);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With