victorpacheco3107
victorpacheco3107

Reputation: 862

Firestore/ionic error - Method snapshotChanges return undefined when call .map

I have a ionic v4 app. When user navigate to profile page clicking on link (routerLink="/profile") I do a query to firestore, and everything is fine, the query is:

let ref = this.asf.collection('posts', ref => ref
  .where('creatorId', '==', creatorId)
  .where("type","==","N")
  .orderBy("createAt", "desc")   
  .limit(count)
).snapshotChanges();
console.log("-----------------");
console.log(ref);
console.log(ref.map);    
console.log("-----------------");
ref.map(actions => {
  return actions.map(a => {
    const data = a.payload.doc.data();
    const id = a.payload.doc.id;
    return { id, ...data };
  });
});

But, when the user enters by typing the url in the browser, ref.map is undefined.

Why when the user enters by typing the url in the browser ref.map return undefined? Any idea or suggestion?

Upvotes: 0

Views: 70

Answers (1)

varman
varman

Reputation: 8894

After upgrading to ^5.0.0-rc.9 it finally works like this: when we use rxjs map, we should use pipe operator.

Try ref.pipe(map(action =>{......}))

Upvotes: 2

Related Questions