在函数外部调用var

时间:2018-04-30 01:36:25

标签: javascript

如何在功能之外调用customerId

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);
          }
      });

0 个答案:

没有答案
相关问题