Hi,
I am a newbie in ionic. I am trying to create a simple app with ionic + sqlite db.
But, every time I run I am getting the following error.
core.js:15714 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'then' of undefined
TypeError: Cannot read property 'then' of undefined
here is the app.component.ts
import { Component } from '@angular/core';
import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite/ngx';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
})
export class AppComponent {
private db: SQLiteObject;
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private sqlite: SQLite
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
this.createDB();
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
private createDB() {
alert('database creating')
this.sqlite.create({
name: 'myDB.db',
location: 'default'
})
.then((db: SQLiteObject) => {
alert('database created')
this.db = db;
// this.createTable();
})
.catch(e => alert(e));
}
}
can anybody help me to solve this.
Regards