Reputation: 408
I am using Firebase to check presence, but the console throws up the following error:
New Firebase failed: First argument must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]".
the following is the code:
new Firebase("https://123654789.firebaseio.com/123654/.info/connected").on('value', function(connectedSnap) {
console.log(connectedSnap.val());
if (connectedSnap.val() === true) {
alert('I am connected!');
} else {
/* we're disconnected! */
alert('not connected!');
}
});
Upvotes: 2
Views: 2827
Reputation: 599541
The .info/connected
path only exists on the top-level of your Firebase data. You cannot access it from child nodes.
So change
new Firebase("https://123654789.firebaseio.com/123654/.info/connected")
To
new Firebase("https://123654789.firebaseio.com/.info/connected")
And the error message will disappear.
Upvotes: 2