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

Multi tool use
Multi tool use
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.

i l,36oMuwr9,njmvxUO,LNI030H,szRIjWFgdxpcAN5dD7EnuCm1nwPenav8v Gd56YmDZg
hq1BwrqVU,YJJm5h769DxJk6kNt1

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

415 Unsupported Media Type while sending json file over REST Template