i dont know what am i doing wrong
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'then' of undefined
TypeError: Cannot read property 'then' of undefined
import {Injectable} from '@angular/core';
import {Plugins} from "@capacitor/core";
import {IonRouterOutlet, Platform} from "@ionic/angular";
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {BehaviorSubject, Observable} from 'rxjs';
import {SQLitePorter} from '@ionic-native/sqlite-porter/ngx';
import {SQLite, SQLiteObject} from '@ionic-native/sqlite/ngx';
@Injectable({
providedIn: 'root'
})
export class UniversalService {
private database: SQLiteObject;
employeelist = new BehaviorSubject([]);
private dbReady: BehaviorSubject<boolean> = new BehaviorSubject(false);
constructor(
private plt: Platform,
private sqlite: SQLite,
private sqlPorter: SQLitePorter,
) {
this.plt.ready().then(() => {
return this.createDB()
});
}
createDB() {
this.sqlite.create({
name: 'emp.db',
location: 'default'
})
//////////////////////////////////////////////////////
GETTING ERROR HERE
//////////////////////////////////////////////////////
.then((db: SQLiteObject) => {
this.database = db;
alert("created!!")
})
.catch(e => {
alert("error " + JSON.stringify(e))
});
}
...