0

How can I call customerId outside of the function?

firebase.auth().onAuthStateChanged(function(user) {
    if (user) {
      var userId = firebase.auth().currentUser.uid;
      console.log("User ID:",userId);

      var database = firebase.database();
      var userId = firebase.auth().currentUser.uid;
      database.ref('stripe_customers/' + userId + '/customer_id').once('value', snapshot => {
          if (snapshot.exists()) {
             var customerId = snapshot.val();
             console.log(customerId);
          }
      });
pushkin
  • 9,575
  • 15
  • 51
  • 95

0 Answers0