SQLite Forum

Expo Problem with Select * in ReactNative. I can’t save the returned query value
Login

Expo Problem with Select * in ReactNative. I can’t save the returned query value

(1) By Morais (001533) on 2020-06-03 21:08:53 [link] [source]

export default function ViewAllUser(){

db = DatabaseConnection.getConnection();

var listUsers = ;

db.transaction(tx => {

tx.executeSql('SELECT * FROM user', [], (tx, results) => {

var temp = [];

for (let i = 0; i < results.rows.length; ++i) {

temp.push(results.rows.item(i));                               

}

listUsers = temp;

});
});

console.log(listUsers);

} export default function ViewAllUser(){

db = DatabaseConnection.getConnection();

var listUsers = ;

db.transaction(tx => {

tx.executeSql('SELECT * FROM user', [], (tx, results) => {

var temp = [];

for (let i = 0; i < results.rows.length; ++i) {

temp.push(results.rows.item(i));                               

}

listUsers = temp;

});
});

console.log(listUsers);

}

Console.log returns an empty array :confused:

(2) By Stephan Beal (stephan) on 2020-06-03 21:25:39 in reply to 1 [source]

The 3rd line has a syntax error, so the rest cannot possibly be running. In any case, this question would be far better directed at the developers of the API you're using. This project only covers the sqlite C API and a few closely-related bits.