如何将 firebase firestore 与我本地的 firebase 模拟器套件连接?
How to connect firebase firestore with my local firebase emulator suite?
对于我的本地开发,我通过 firebase cli 安装了 firebase 模拟器。
现在我想让我的项目连接到模拟的 firebase。
与模拟 Auth 的连接已经 运行 正常。
我正在尝试在 firebase.firestore() 上使用“useEmulator”
我的代码基本上来自文档(https://firebase.google.com/docs/emulator-suite/connect_firestore#web)
const db = firebase.firestore()
const auth = firebase.auth()
if (location.hostname === "localhost") {
console.log('LOCAL')
auth.useEmulator("http://localhost:9099")
db.useEmulator("localhost", 8080)
}
我收到这个错误Uncaught TypeError: s.useEmulator is not a function
在这一行:db.useEmulator("localhost", 8080)
我错过了什么?感谢您的帮助!
我在 slacks firebase 社区上得到了这个提示:
确保您的 SDK 版本支持“useEmulator”(https://firebase.google.com/support/release-notes/js) 或对旧版本使用此代码:
FirebaseService.db.settings({
host: 'localhost:8080',
ssl: false,
experimentalForceLongPolling: true,
})
对于我的本地开发,我通过 firebase cli 安装了 firebase 模拟器。 现在我想让我的项目连接到模拟的 firebase。
与模拟 Auth 的连接已经 运行 正常。
我正在尝试在 firebase.firestore() 上使用“useEmulator” 我的代码基本上来自文档(https://firebase.google.com/docs/emulator-suite/connect_firestore#web)
const db = firebase.firestore()
const auth = firebase.auth()
if (location.hostname === "localhost") {
console.log('LOCAL')
auth.useEmulator("http://localhost:9099")
db.useEmulator("localhost", 8080)
}
我收到这个错误Uncaught TypeError: s.useEmulator is not a function
在这一行:db.useEmulator("localhost", 8080)
我错过了什么?感谢您的帮助!
我在 slacks firebase 社区上得到了这个提示:
确保您的 SDK 版本支持“useEmulator”(https://firebase.google.com/support/release-notes/js) 或对旧版本使用此代码:
FirebaseService.db.settings({
host: 'localhost:8080',
ssl: false,
experimentalForceLongPolling: true,
})