Function to return only the requests to the logged-in user in question

1

I have following code to save the requests:

save(pedido: any) {
var userId = firebase.auth().currentUser.uid
return new Promise((resolve, reject) => {
  if (pedido.key) {
    this.db.list("pedidos")
      .update(pedido.key, { name: pedido.name, cnpj: pedido.cnpj })
      .then(() => resolve())
      .catch((e) => reject(e));
  } else {
    this.db.list('pedidos')
      .push({ name: pedido.name, cnpj: pedido.cnpj })
      .then(() => resolve());
  }
})

}

And the following code to bring only the requests of the logged in user:

getAll() {
var userId = firebase.auth().currentUser.uid
return this.db.list('pedidos', ref => ref.equalTo(userId))
  .snapshotChanges()
  .map(changes => {
    return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));

  })

}

And I call it in the menu.ts through its constructor:

 pedidos: Observable<any>;

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

But it does not return any requests. What am I doing wrong ???????

    
asked by anonymous 21.09.2018 / 13:24

0 answers