I have a problem wanting to read a data by id =, it does not show me the email that I keep in that id

1

I try to read a data by id = which is an email that I receive through Firebase, everything works well within the auth, it reads the data from the Database and shows it in the WebApp, however when I want to read the data to through the id = outside of Firebase's auth it does not show me any value.

This is the id = in html

<p id="user_para2"></p>

Here it reads the data without problems from the database and shows it in the id = user_para2

firebase.auth().onAuthStateChanged(function(user) {
  if (user) {
    // User is signed in.

    document.getElementById("user_div").style.display = "block";
    document.getElementById("login_div").style.display = "none";

    var user = firebase.auth().currentUser;

    if(user != null){

      var email_id = user.email;
      document.getElementById("user_para1").innerHTML = "Bienvenido Usuario: ";
      document.getElementById("user_para2").innerHTML = email_id;

      //if (email_id != "[email protected]") { firebase.auth().signOut(); }

    }

  } else {
    // No user is signed in.

    document.getElementById("user_div").style.display = "none";
    document.getElementById("login_div").style.display = "block";

  }
});

The problem arises when I try to read the email that is stored in the id = user_para2 outside of the Firebase.auth code ... I am reading it this way and it does not show me the email it has stored in that id.

var email_id = document.getElementById("user_para2").innerHTML;      

console.log("Este email es " + email_id);

In the console as a result shows me this

Este email es 

This is the firebase.auth code

firebase.auth().onAuthStateChanged(function(user) {
  if (user) {
    // User is signed in.

    document.getElementById("user_div").style.display = "block";
    document.getElementById("login_div").style.display = "none";

    var user = firebase.auth().currentUser;

    if(user != null){

      var email_id = user.email;
      document.getElementById("user_para1").innerHTML = "Bienvenido Usuario: ";
      document.getElementById("user_para2").innerHTML = email_id;

      //if (email_id != "[email protected]") { firebase.auth().signOut(); }

    }

  } else {
    // No user is signed in.

    document.getElementById("user_div").style.display = "none";
    document.getElementById("login_div").style.display = "block";

  }
});

What can be the problem for which it does not show the data when I call it by the id, being that if the mail is shown on the web?

Thank you very much for your time, I hope you can help me!

    
asked by Matías Nicolás Núñez Rivas 05.04.2018 в 03:42
source

0 answers