IT’S RETURN CANNOT READ PROPERTY ‘executeSQL’ of undefined, in other page it’s work but in page orcamento.ts it’s got error
ionViewDidEnter(){
this.database.buscaTipoeCliente()
.then((data) => {
this.tipovenda = data[0].tipovenda;
this.database.presentToastError(this.tipovenda);
this.tipodepreco = data[0].tipodepreco;
this.database.presentToastError(this.tipodepreco);
}, (error) => {
this.database.presentToastError(JSON.stringify(error.message));
this.database.presentToastError(JSON.stringify(error.status));
});
}
public buscaTipoeCliente(){
return new Promise((resolve, reject) => {
this.storage = new SQLite();
this.storage.openDatabase({name: "infosysDB.db", location: "default"})
.then(
(success) => {
this.storage.executeSql("SELECT * FROM preferencias", [])
.then((data) => {
if(data.rows.length > 0 ){
data = [{"tipovenda": data.rows.item(0)['tipo'], "cliente": data.rows.item(0)['cliente'], "codigo": data.rows.item(0)['codigo'], "tipodepreco": data.rows.item(0)['tipodepreco']}]
resolve(data);
}else if(data.rows.length <= 0){
data = "avista";
resolve(data);
}
},
(error) => {
this.presentToastError(JSON.stringify(error.message + "database"));
reject(error)
console.log("não foi possivel carregar a tabela preferencias.");
})
},
(error) => {
reject(error);
this.presentToast("Não foi possível abrir a base de dados!");
});
});
}