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中会弹出缺少的参数括号错误?我关闭了所有打开的括号。哪里缺少?
答案 0 :(得分:1)
更改此行:
app.get("/editMBTI", editMBTIFunc(req, res)
到此:
app.get("/editMBTI", function editMBTIFunc(req, res)
仅供参考,像JSHint或JSLint这样的工具通常会为您提供有关错误位置的详细信息(这是我以前更容易看到的内容)。