javascript - .get() requires callback functions but got a [object Undefined] -
i working mongoose.
i wrote 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 defined or undefined. not able check it. if comment whole body of exports.listdoc, same error. assume here here getting model. model.find(function(err, models) { if (err) { res.render('error', { status: 500 }); } else { res.jsonp(models); } }); };
bu getting error :
.get() requires callback functions got [object undefined]
how resolve it?
you have docs.listdocs
instead of docs.listdoc
. that's why it's undefined
.
app.get('/listdoc', docs.listdoc/*s*/);
Comments
Post a Comment