【发布时间】:2021-09-15 13:16:04
【问题描述】:
所以,基本上我正在尝试将数据保存在 firebase 中,但出现错误“未定义 firebase” 我的代码:-
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.1/firebase-app.js";
const firebaseConfig = {
apiKey: "",
authDomain: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: ""
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
firebase // getting error over here
.firestore()
.collection("books")
.add({
title: "Of Mice and Men",
})
.then((ref) => {
console.log("Added doc with ID: ", ref.id);
// Added doc with ID: ZzhIgLqELaoE3eSsOazu
});
【问题讨论】:
标签: javascript html google-cloud-firestore