How to get Firebase reference when using Polymerfire? -


i new polymer , stuck on setting database data. manged make email authentication work , need save user data after user creation. initialize app firebase-app element.

here important part:

this.$.auth.createuserwithemailandpassword(email, pass).then(function (user) {                     user.sendemailverification();                     document.getelementbyid("emaildialog").toggle();                     var view = document.getelementbyid("r_view");                      firebase.database().ref('/user/' + user['uid']).set({                         name: view.name,                         surname: view.surname                     }).catch(function (err) {                         console.log(err.message);                     });                 }) 

user created user data won't saved and

firebase.database not function"

error thrown. guess it's because don't have access firebase.database function in scope. found many ways how solve issue using pure javascript, i'm not sure official "polymer way".

edit: still can't work. managed reference of app object seems there no database method available. wrote simple function debugging:

    debugfunction: function () {         if (!!this.user) {             var fb = this.$.auth.app;             console.log(!!fb); // output true,             var database = fb.database();          }     } 

i "uncaught typeerror: fb.database not function(…)" once more.

thanks in advance, jan

you can reference of firebase app inside firebase-auth element. make sure outside of callback function won't have deal getting proper scope of this. if must, can .bind or arrow functions.

var app = this.$.auth.app; 

then after can app.database() replacement firebase one.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -