我使用expressJS和postgresql,但是Promise有问题,我需要验证电子邮件是否存在。.
错误消息是: UnhandledPromiseRejectionWarning
这是我的职责
function checkEmail(email){
return new Promise((resolve, reject) => {
pool.query("SELECT * FROM tb_users where email=$1", [email] , function(error, result) {
if(!error){
console.log("EMAIL COUNT : "+result.rows.length);
return resolve(result.rows.length > 0);
} else {
console.log(error)
return reject(new Error('Database error!!'));
}
});
});
}
感谢您的回答