0

I have a function one and a Firebase authstatechange function inside it but I can't reach the function two outside. the code:

function one() {

    firebase.auth().onAuthStateChanged(function(user) {
        //code here

        function two() {
            //code here
        }
    });
}
// how to call function two here?
Sébastien
  • 11,860
  • 11
  • 58
  • 78
Andras
  • 109
  • 1
  • 1
  • 7

1 Answers1

2

Define your function two() outside and call it from inside the onAuthStateChanged callback

function two() {
   //code here
}

function one() {
    firebase.auth().onAuthStateChanged(function(user) {
        //code here
        two()
    });
}
Sébastien
  • 11,860
  • 11
  • 58
  • 78
  • But how to call it? Function one and the firebase function has several other functions and I would like the function two called only. – Andras Feb 20 '18 at 16:53