javascript - Polymerfire TypeError -
i new polymer , i'm trying save user data using firebase-document component.
here relevant code snippets:
component initialization:
<firebase-document id="document" app-name="nameoftheapp" path="[[userdatapath]]" data="{{userdata}}"> </firebase-document>
and javascript part:
polymer({ is: 'registration-view', properties: { userdata: object, userdatapath: { type: string, notify: true } }, debugfunction: function () { user = this.domhost.user; this.userdatapath = '/users/' + user.uid; this.userdata.firstname = "fname"; this.userdata.lastname = "lname"; console.log(user); console.log(this.userdatapath); this.$.document.save(this.userdatapath).then(function () { console.log("success"); }); }, ......
when call debug function
uncaught (in promise) typeerror: c[b] not function(…).
stacktrace:
1) debugfunction @ registration-view.html:106 2) save @ firebase-document.html:82 3) (anonymous function) @ firebase-document.html:93 4) c @ firebase-app.js:formatted:939
the error thrown in minimized firebase-app.js file not smart that. configured properly. user authentication works well, app name fine(if weren't app not initialized error thrown).
i tried mock data in database , firebase-document doesn't load them. set database rules data public eliminate potential authorization problems didn't help.
{ "rules": { // ".read": "auth != null", ".read": true, // ".write": "auth != null" ".write": true } }
attempt 2:
i found another way how save data , here code:
<firebase-document id="document" app-name="doctor-appointment-system" log> </firebase-document>
javascript part:
debugfunction: function () { this.$.document.path = null; this.$.document.data = { 'firstname': this.$.fninput.value, 'lastname': this.$.lninput.value }; console.log('users/' + this.domhost.user.uid); this.$.document.save('users', this.domhost.user.uid); },
with setup getting error. here output console:
users/z5uaeyo2s1g2jyclpkk1vtw130i2
app-storage-behavior.html:350 setting firebase value @ users/z5uaeyo2s1g2jyclpkk1vtw130i2 object {firstname: "", lastname: ""}
firebase-database-behavior.html:61 uncaught (in promise) typeerror: cannot read property 'ref' of undefined(…)_setfirebasevalue
it fails on following line in firebase-database-behaviour.html:
var result = this.db.ref(path).set(leaf ? value.$val : value);
it looks there problem configuration authentication works fine clueless.
i'm stuck on 1 appreciated.
thanks, jan
i found solution still not sure essence of issue. structure of application of single page app. have core-scaffold element consists of toolbar, app-route, iron-pages , firebase-auth element. code above situated in registration-view lazy loaded iron-pages when adequate url matches. tried move code directly core-scaffold file , worked fine. , surprisingly when called code in registration view worked. turned out if import firebase-document.html in core-scaffold.html error won't thrown in children.
if explains cause i'll grateful.
thanks, jan
Comments
Post a Comment