M'Boulas M'Boulas - 6 months ago 623
Javascript Question

new firebase: Error: Must pass a valid Firebase reference to $firebaseArray (not a string or URL)

For some reason, with this new firebase,

$firebaseArray
does not seem to work. I've tried
$firebaseArray(firebase.database().ref('users'))
but I'm getting this message:


Error: Must pass a valid Firebase reference to $firebaseArray (not a string or URL)


Your help will be greatly appreciated.

Answer

You're using the firebase client library version 3 with the current version of angularfire, which doesn't yet support version 3. There's a pull request for an upgraded angularfire version that is in review and the author claims to be ready to release it imminently . See https://github.com/firebase/angularfire/pull/717

In the meantime, you can either not use angularfire (see workaround below) or you can revert to the old firebase client library.

[EDIT] - Apparently this snippet isn't really an acceptable workaround because it doesn't return an array, but rather an object. Please disregard...

   
var self = this;
var usersRef = firebase.database().ref("users");
             usersRef.on('value', function(snapshot) {
                 self.users = snapshot.val();
             });