Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda