AngularJS: v1.5.11 Firebase: v3.6.9 Angularfire: v2.3.0
I want to get the key. After creating the JSON object my code :
}).then(function(ref){
var id = ref.key();
console.log("Added User with ID: "+id);
The value is inserted in the firebase DB but getting this error and nothing is shown in the console log.
I guess the syntax to get the key is changed with these versions. I don't know what the ref.key()
is used for really. Is it required as to set some primary key?
Reference.key()
used to be a function in Firebase JavaScript SDK 2.x. But is is now a read-only property, so you should use ref.key
.
This and many more things to be aware of when upgrading your code are covered in the Firebase migration guide for web developers: https://firebase.google.com/support/guides/firebase-web