Reputation: 197
i included these cdn in my html:
<script src="https://www.gstatic.com/firebasejs/7.6.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js"></script>
<script src="StoreFeatured.js" type="text/javascript"></script>
and here is the store featured code
var firebaseConfig = {
apiKey: "$$$$$$$",
authDomain: "$$$$$$",
databaseURL: "https://thegreatpcstore.firebaseio.com",
projectId: "thegreatpcstore",
storageBucket: "thegreatpcstore.appspot.com",
messagingSenderId: "302435893791",
appId: "$$$$$$$",
measurementId: "G-0GH3F41E5S"
};
firebase.initializeApp(firebaseConfig);
new function GetData()
{
firebase.database().ref('/Products/Motherboard/1').once('value').then(function (snapshot) {
//var Description = snapshot.val().Description;
var Name = snapshot.val().Name;
var Price = snapshot.val().Price;
var ImageStr = snapshot.val().ImageStr;
document.getElementById("Mi"+i).src=ImageStr;
document.getElementById("Mn"+i).innerHTML=Name;
document.getElementById("Mp"+i).innerHTML=Price;
}
)
}
what am i doing wrong?
im getting these errors:
> firebase-auth.js:206 Uncaught Error: Cannot find the firebase namespace; be sure to include firebase-app.js before this library.
at firebase-auth.js:206
at firebase-auth.js:206
at firebase-auth.js:206
>
> firebase-database.js:38 Uncaught Error: FIREBASE FATAL ERROR: Failed
> to register the Firebase Database Service (TypeError:
> firebase.INTERNAL.registerService is not a function)
> at dd (firebase-database.js:38)
> at firebase-database.js:245
> at firebase-database.js:245
>
> StoreFeatured.js:17 Uncaught TypeError: firebase.database is not a
> function
> at new GetData (StoreFeatured.js:17)
> at StoreFeatured.js:13
first line of getdata() is doing problem i think im doing something wrong with cdn... please help
if i remove the cdn it gives one error:
StoreFeatured.js:16 Uncaught TypeError: firebase.database is not a function
at new GetData (StoreFeatured.js:16)
at StoreFeatured.js:13
Upvotes: 3
Views: 2359
Reputation: 149
Instead of using various CDN use a single CDN which include all the library:
script src="https://www.gstatic.com/firebasejs/7.14.4/firebase.js"
Upvotes: 0
Reputation: 80942
Update both the firebase-auth and firebase-database to the following version:
<script src="https://www.gstatic.com/firebasejs/7.6.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.6.1/firebase-database.js"></script>
Upvotes: 7