首页 > 解决方案 > 将值传递给 Firestore 数据库

问题描述

数据没有被推送到我的 Firestore,我不知道为什么以及我做错了什么创建了 Web 应用程序 ,然后是文档。我卡住感觉脑死了

我的文档中的脚本

// Write data to  firestore

<script src="https://www.gstatic.com/firebasejs/9.0.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.0.1/firebase-firestore.js"></script>
<script>
const firebase = require("firebase");
// Required for side-effects
require("firebase/firestore");

// Initialize Cloud Firestore through Firebase
firebase.initializeApp({
  apiKey: 'mykey',
  authDomain: 'myauthdomain',
  projectId: 'myprojectid'
});


var db = firebase.firestore();

db.collection("felanmalan").add({
    namn: "firstname surname",
    epost: "mail@gmail.com",
    tel: "myphonenumber",
    fast: "where i live",
    meddelanse: "whats wrong with appartment"
})
.then((docRef) => {
    console.log("Document written with ID: ", docRef.id);
})

</script>

当我按下回车键时,我在想数据会被传递到我的 Firestore,但什么都没有。我以为这很容易,但事实并非如此。我之前通过 php 到 mysql 完成了一些 html 表单,但这似乎超出了我的想象。有人可以解释我如何在极其基础的水平上完成这项工作。

我的最终目标是拥有一个将数据发送到 Firestore 的 html 表单,然后使用 Zapier 函数将最后的数据发送出去。不会为此设置另一个 smtpserver 大声笑!

标签: javascripthtmlgoogle-cloud-firestore

解决方案


推荐阅读