IONIC 3 - TypeError: Object(…) is not a function

Multi tool use


IONIC 3 - TypeError: Object(…) is not a function
I'm newbie on Ionic with Firebase, I have this error when I run the app :
TypeError: Object(...) is not a function
That's the different part of codes :
In 'ts' file :
items : AngularFireList<any>;
itemArray = ;
this.items = afs.list("persons");
this.items.snapshotChanges().subscribe(actions =>{
actions.forEach(action=>{
let y = action.payload.toJSON();
y['$key'] = action.key;
this.itemArray.push(y as Person);
})
})
Html :
<ion-item-sliding *ngFor = "let person of itemArray">
...
I've installed a latest version of firebase and angularfire2 :
npm install firebase angularfire2 --save
npm install @firebase/app@latest --save
Current configuration in app.module.ts :
"angularfire2": "^5.0.0-rc.11",
"firebase": "^5.3.0",
"ionic-angular": "3.9.2",
"ionicons": "3.0.0",
"rxjs": "5.5.11",
I recommend not using angularfire. In my experience, it was a headache maintaining and updating it. Firebase SDK itself provides enough functionality for you.
– Ari
yesterday
I resolve the bug by running this command : npm i rxjs@6 rxjs-compat@6 promise-polyfill --save
– Tchiko
yesterday
1 Answer
1
Make sure your function calls return non-null values:
items : AngularFireList<any>;
itemArray = ;
this.items = afs.list("persons");
if(this.items){
this.items.snapshotChanges().subscribe(actions =>{
actions.forEach(action=>{
if(action && action.payload){
let y = action.payload.toJSON();
y['$key'] = action.key;
this.itemArray.push(y as Person);
}
})
})
As a side note I recommend not using angularfire. In my experience, it was a headache maintaining and updating it. Firebase SDK itself provides enough functionality for you.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I used this command for resolving the error : npm i rxjs@6 rxjs-compat@6 promise-polyfill --save
– Tchiko
2 days ago