0

I'm trying to do a multi-path update using Firebase and AngularFire2. However, I'm getting the error above when I use this:

let fb = firebase.database().ref();
let key = fb.child('/path').push().key();

Any ideas of how I can get the key after pushing something using AngularFire2?

adjuremods
  • 2,938
  • 2
  • 12
  • 17
brians69
  • 485
  • 2
  • 11
  • 24

1 Answers1

1

As the push method now returns an Observable, the proper way to get the generated $key (using AF2) is doing the following:

let fb = this.af.database.list('/path');
fb.push('item').then(res => console.log(res.key));
brians69
  • 485
  • 2
  • 11
  • 24