如何在功能之外调用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);
}
});