【发布时间】:2022-02-15 08:22:14
【问题描述】:
我正在尝试从 push 函数中获取唯一键,但每当我调用它时,我都会收到此错误:Uncaught TypeError: postsRef.push is not a function at HTMLFormElement。 这些是我的导入:
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.6/firebase-app.js";
import { getDatabase, set, ref, update, onValue, remove, push } from "https://www.gstatic.com/firebasejs/9.6.6/firebase-database.js";
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword, onAuthStateChanged, signOut } from "https://www.gstatic.com/firebasejs/9.6.6/firebase-auth.js";
这些是我用来调用推送函数的行:
const app = initializeApp(firebaseConfig);
const db = getDatabase(app);
const postsRef = ref(db, 'devices/');
const newPostRef = postsRef.push();
希望大家能帮帮我,谢谢
【问题讨论】:
标签: javascript firebase-realtime-database