Here i'm checking with the collection keys, the apikey which im passing in postman it showing invalid credentials. the console value showing null. Dont know where im doing wrong thanks in advance
const fKey = await Key.findOne({
password: req.params.apikey,
active: true
});
console.log("fKey....",fKey)
CodePudding user response:
You Are Passing params instead of query in code
const fKey = await Key.findOne({
password: req.query.apikey,
active: true
});
console.log("fKey....",fKey)
please look at this link for a better understanding.
CodePudding user response:
The problem is not with MongoDB query. It is with request handling. You are using req.params.apikey instead of req.query.apikey.
const fKey = await Key.findOne({
password: req.query.apikey,
active: true
});


