3

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
2
  • 2
    Shouldn't you be using the same version in all firebase dependencies ? I see 7.6.1 and 3.1.0. Commented Dec 29, 2019 at 21:39
  • i copied it from an answer did not looked at it :( Commented Dec 29, 2019 at 21:40

2 Answers 2

7

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>
Sign up to request clarification or add additional context in comments.

1 Comment

thanks you so much did not realized it was that simple!
0

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" 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.