export const validateCredentials = async (user: User): Promise<boolean> => {
let result;
connection.query('SELECT password from users WHERE email = ? AND password = ?', [user.email, user.password], (err: QueryError, rows: RowDataPacket[]) => {
console.log(rows[0][user.password]); //this is the users password
result = rows[0][user.password];
});
console.log(result) // result is always undefined
return result != undefined;
};
the provided email and password are correct and rows[0][user.password] is holding a value. now i want to return this value outside the callback function, how do i do that?
the provided email and password are correct and rows[0][user.password] is holding a value. now i want to return this value outside the callback function, how do i do that?