Bring only authenticated user data to the screen

0

I'm developing an app with ionic3 and Firebase.

I'm trying to bring in only requests from a particular user, but I'm having problems. When I call the getAll() function it brings all the requests from the database. But when I call the function to bring only the requests of the user that is currently authenticated, it does not bring anything.

The function getAll() is being called and as follows:

class PedidoProvider
    getAll() {
    return this.db.list('pedidos', ref => ref.orderByChild('name'))
      .snapshotChanges()
      .map(changes => {
        return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));

      })
  }
Class menu.ts :
pedidos: Observable<any>;

And in the constructor I call:

this.pedidos = this.provider.getAll();

Function getListaUsuario :

getListaUsuario() {
    var userId = this.afProvider.auth.currentUser.uid;
    return firebase.database().ref('pedidos' + userId).once('value').then(function(snapshot) {
       return snapshot.val();  

    });
}
    
asked by anonymous 20.09.2018 / 14:28

0 answers