.get() requires callback functions but got a [object Undefined]

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 {

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*/);


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.