Hello everyone,
I am trying to save to my Firebase database and I am using import using the URLs in JavaScript. It keeps returning database is not a function
in the console. Please help me figure this out.
Error In Console:
database is not a function
My Code: (JavaScript)
import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.0.0/firebase-app.js';
import { getDatabase } from 'https://www.gstatic.com/firebasejs/9.0.0/firebase-database.js';
const firebaseApp = initializeApp({
apiKey: "~",
authDomain: "~",
projectId: "~",
storageBucket: "~",
messagingSenderId: "~",
appId: "~",
measurementId: "~"
});
const database = getDatabase(firebaseApp);
database().ref("lol").set(true);
My Code: (HTML)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>~</title>
<link rel="stylesheet" href="/style.css">
<script type="module" src="/script.js" defer></script>
</head>
<body>
</body>
</html>
Thank you!