我正在使用expressjs
和MongoDB
进行api调用以获取文档ID
这是我的api端点,但是它返回一个空数组...
router.route("/instructor/validate/:usernamePassword").post((req, res) => {
let id = req.params.usernamePassword;
let idd = id;
let username = id.split("-", 1).toString(); //b@gmail.com
let password = idd.split("-")[1].toString(); // ********
InstructorDB.find({ email: username }, (err, data) => {
if (err) throw err;
passwordData = data.password; //gives empty value
if (password == passwordData) {
res.status(200).send("id is: " + data._id);
} else {
res.status(400).send("nottttt found");
}
});
谁能告诉我我哪里出问题了?