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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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 used this command for resolving the error : npm i rxjs@6 rxjs-compat@6 promise-polyfill --save
– Tchiko
2 days ago





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.

Popular posts from this blog

Poland

Jenkinsfile syntax highlighting in Java project using Intellij Idea

Web Scraping Python Beautiful Soup