javascript - 在函数外调用 var
问题描述
如何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);
}
});
解决方案
推荐阅读
- python-3.x - 我正在关注一个 tensorflow 程序,但那里的代码已损坏,我不知道如何修复它
- c# - C# Dapper 查询中的多个实体:参数过多
- c# - 如何配置自包含的单文件程序?
- python - 用 sqlalchemy 覆盖 postgresql onupdate
- c# - 可以在另一个属性的 setter 中设置不同属性的值吗?
- go - 使用 OpenSSL 的 EVP API 的配置文件
- x86 - x64中完全不使用分段吗?
- bash - 下载前让 curl 等待
- skorch - Skorch:帮助为多个输出构建分类器
- spring-boot - OppenId 通过 Spring Security OAuth2 连接配置