I have a method "GenerateTokenString()" that generates a random key after creating the key i passed it to a function IsTokenExists but this function returns undefines although their is a key exists in the database.
key = GenerateTokenString();
//Check if key already exists
var isExists=IsTokenExists(key) //undefined
function IsTokenExists(key){
Token.findOne({token:key}).then(doc=>{
console.log(doc)
return doc
}).catch(err=>{
console.log(err)
return err
})
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…