I want to create a website using Firebase and Polymer.
There is no need for login (if changed in the Firebase console.firebase.google.com).
Here are the database rules:
{
"rules": {
".read": "true",
".write": "auth != null"
}
}
This should be OK for anyone with access to the app.
Yet, when I try to query an element, I get zero results (an empty array).
In short, the code is like this:
<firebase-app auth-domain="xyz.firebaseapp.com"
database-url="https://xyz.firebaseio.com/"
api-key="AIzaSyB7md4GqkXA-hsEF_CLU3ryHj-xxxxxxxxxx">
</firebase-app>
<firebase-document
path="/organizers/"
data="{{noteData}}">
</firebase-document>
{{noteData}}
<firebase-query
id="query"
path="/organizers/"
data="{{data}}">
</firebase-query>
{{data}}
</template>
<script>
Polymer({
is: 'my-app',
properties :{
data: {
type:Object,
observer: 'dataChanged'
}
},
dataChanged: function (newData, oldData){
console.log('new data: '+ newData);
console.log('old data: '+ oldData);
}
});
</script
There is data in the database.
I don't get why no data is being retrieved. I don't need the firebase-auth element, since I'm doing an anonymous access off the data, right?
I think that with your given code, your data is actually fetched. You can remove the
<firebase-document>
and in your query add a reference to your firebase app object by specifying an app-name.
There isn't a lot of documentation about the app name but I think it functions as a namespace.
Furthermore, there is a problem with how you log the data. Try removing the "new data:" and "old data:" parts from your logging so that the browser dev tools can infer the datatype and display it correctly (as an object/array in your case).
As for your firebase-document, if you want to keep it, the data attribute is bound to "noteData" and not "data"