Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Getting the result value out of Sqlite3 callback function

I'm using Sqlite3 in an Express back-end with a React front-end. So I'm trying to check if there is a user with a certain email in the database. I've got the function below, which is not finished yet, but the issue I'm having is that I cannot return the result.

Is there a way to return the result variable from the callback function or do I only have access to it inside the callback function?

When finished the function should be returning the email of the user if they exists or false if they don't exist in the database.

getUserByEmail = () => {
    database.get(getUserByEmailQuery, [], (err, result) => {
        if (err) {
            console.log(err.message);
        }
        console.log(result.emailAddress);
        return result;
    });
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I just solved it an hour or so ago. Not the smartest solution, but what I did was just use a different package for the database.

So I used better-sqlite3 which makes it possible to just store the result from the database query into a variable.

Here is the updated code:

exports.getUserByEmail = (email) => {
    const result = betterSqlite3DB.prepare(getUserByEmailQuery).get(email);
    return result;
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!