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

108
Vistas
Scope of variable in WebSQL

I have this function

const _getCountriesByContinentCode = continent_code => {
    const someDb = SQLite.openDatabase(db);
    let foo = [];
    someDb.transaction(tx => {
        tx.executeSql("SOME SQL", [], (tx, results) => {
            for (let i = 0; i < results.rows.length; i++) {
                foo.push((results.rows.item(i)));
            }
            console.log('####', foo) // this logs the result as expected
        });
    });
    console.log('****', foo) // this does not log the pushed result, but an empty array 
}

The console.log('####', foo) logs as expected the results of foo.push(...). However, the console.log('****', foo) logs an empty array.

Why is that? Is someDb.transaction(... asynchronus?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Indeed, as @Bergi suggest in the comment below the Q: SQL.transaction and SQL.executeSql are both asynchronous.

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