javascript - 一个 Web 应用程序的多个项目配置
问题描述
我正在开发一个网络应用程序。我将我的网站部署到一个项目,并希望从另一个项目中获取 firestore 数据。所以我在 html 文件中添加了两个项目配置。为了从第二个 firebase 项目中调用数据,我声明了一个如下所示的变量。
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
storageBucket: "<BUCKET>.appspot.com",
};
var secondaryAppConfig = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
storageBucket: "<BUCKET>.appspot.com",
};
var secondary = firebase.initializeApp(secondaryAppConfig, "secondary");
var secondaryFirestore = secondary.firestore();
secondaryFirestore.collection('sample').get().then(snap => {
var size = snap.size;
console.log("TotalSample",size);
// will return the collection size
document.getElementById('totalStores').textContent = size;
});
当我像上面那样编写查询以从 secondaryFirestore 获取数据时,我收到如下错误
error.js:149 Uncaught (in promise) Error: Missing or insufficient permissions.
at new e (error.js:149)
at t.fromRpcStatus (serializer.js:93)
at t.fromWatchChange (serializer.js:573)
at e.onMessage (persistent_stream.js:391)
at persistent_stream.js:333
at persistent_stream.js:308
at async_queue.js:83
Project-A 数据库规则就像只有经过身份验证的人才能访问数据。我无法更改该规则,因为它是机密的。实际上,在这两个数据库项目中,我都使用相同的电子邮件 ID 进行签名。我在这一点上构造。我试了很多都想不通。请让我知道有关如何从 secondaryFirestore 数据库访问数据的任何想法。
提前致谢。
解决方案
推荐阅读
- java - 使用某些端点或类的 azure id_token 有效性
- c# - 单击按钮时调用带参数的方法
- mongodb - PyMongo for MongoDB 中的 find_one_and_update() 和 update_one() 之间的区别?
- javascript - 用条纹充电
- r - 如何更改使用 R 中的 plotly 包生成的对数刻度图的刻度值?
- javascript - 使用绑定调用 javascript 函数
- c# - 在 RichTextBox 中以 SQL 配色方案显示字符串?
- c++ - 递归模板:继承与组合
- python - 在特定条件下从数据框中减去值并将其余值添加到下一个值
- python - 从组中选择 n 行