I have a table that is being populated by firebase database values. When I launch the application, I obtain the following error: Uncaught SyntaxError SyntaxError: The requested module ‘https://www.gstatic.com/firebasejs/9.8.3/firebase-app.js’ does not provide an export named ‘child’ at (program)
Can someone provide a solution
HTML and JS code
<script src="./index.js"></script> <script type="module"> // Import the functions you need from the SDKs you need var id = 0; var tbody = document.getElementById('tbody1'); function addItem(First_Name, Last_Name, Password, Phone_Number, Email, Account_Status) { let trow = document.createElement("tr"); let td1 = document.createElement('td'); let td2 = document.createElement('td'); let td3 = document.createElement('td'); let td4 = document.createElement('td'); let td5 = document.createElement('td'); let td6 = document.createElement('td'); td1.innerHTML = First_Name; td2.innerHTML = Last_Name; td3.innerHTML = Password; td4.innerHTML = Phone_Number; td5.innerHTML = Email; td6.innerHTML = Account_Status; trow.appendChild(td1); trow.appendChild(td2); trow.appendChild(td3); trow.appendChild(td4); trow.appendChild(td5); trow.appendChild(td6); tbody.appendChild(trow); } function AddAllItemsToTable(users) { tbody.innerHTML = ""; users.forEach(element => { addItem(element.First_Name, element.Last_Name, element.Password, element.Phone_Number, element.Email, element.Account_Status); }); }
Advertisement
Answer
You’re trying to import the Realtime Database functions from the wrong SDK.
Change the import to:
import { getDatabase, ref, child, get } from "https://www.gstatic.com/firebasejs/9.8.3/firebase-database.js";
So firebase-database.js
instead of firebase-app.js
.