Alright. Two things.
So you almost never want to type function
inside an Ionic app. Instead, you want to utilize the fat arrows syntax () =>
.
Secondly, Promise nesting is an anti-pattern and should be avoided.
That being said, here’s what I’d suggest:
this.sqlite.create({
name: 'data.db',
location: 'default'
})
.then((db: SQLiteObject) => {
console.log('SELECT * FROM message');
return db.executeSql('SELECT * FROM message', {});
})
.then((data) => {
for(let i = 0; i < data.rows.length; i++) {
let id = data.rows.item(i).id;
let message_to = data.rows.item(i).message_to;
let message_text = data.rows.item(i).message_text;
this.messages.push({
id: id,
message_to: message_to,
message_text: message_text
});
}
})
.catch(e => console.log(e));