缺少参数列表括号错误

时间:2018-01-26 17:19:41

标签: javascript node.js mongodb

app.get("/editMBTI", editMBTIFunc(req, res)
{
    // making MongoClient available to all the EJS Files
    // app.locals.MongoClient= MongoClient;
    MongoClient.connect(url, function (err, client) {
        assert.equal(null, err);
        console.log("Connected Successfully to the Database server");
        const db = client.db(dbName);
        //getting the whole collection of MBTI sets
        var cursor = db.collection("mbti_testcontent").find();
        cursor.each(function (err, doc) {
            console.log(doc);
            //send the above retrieved doc to the editMBTI.ejs file(front- end)
            res.render('editMBTI', {
                'mbti_content': doc,
                'db_url': url,
                'dbName': dbName
            });
        });
    });
});

以上是终端的代码和图像(https://i.stack.imgur.com/XcOti.png)。为什么editMBTI api中会弹出缺少的参数括号错误?我关闭了所有打开的括号。哪里缺少?

1 个答案:

答案 0 :(得分:1)

更改此行:

app.get("/editMBTI", editMBTIFunc(req, res)

到此:

app.get("/editMBTI", function editMBTIFunc(req, res)

仅供参考,像JSHint或JSLint这样的工具通常会为您提供有关错误位置的详细信息(这是我以前更容易看到的内容)。