In my current project, I am using Sqlite3 with an Express backend along with a React frontend. My goal is to verify if a user with a specific email exists in the database. While working on the function provided below, which is still a work in progress, I encountered difficulty in returning the result.
I am wondering if it is possible to return the variable result
from the callback function or if it is only accessible within the callback function itself?
Once completed, this function should return the user's email if they exist in the database, or false if they do not.
getUserByEmail = () => {
database.get(getUserByEmailQuery, [], (err, result) => {
if (err) {
console.log(err.message);
}
console.log(result.emailAddress);
return result;
});
};