i am trying to connect and fetch data from my firebase firestore database but I am having error on firebase.initializeApp(firebaseConfig);
error is Uncaught ReferenceError: firebase is not defined I tried may ways that were told on different websites ut nothing worked kindly help my code is
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script>
<script src="https://www.gstatic.com/firebasejs/9.22.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.22.1/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.22.1/firebase-auth.js"></script>
<script src="https://code.jquery.com/jquery-3.7.0.js" ></script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
// Firebase configuration
var firebaseConfig = {
apiKey: "{{ config('services.firebase.apiKey') }}",
authDomain: "{{ config('services.firebase.authDomain') }}",
projectId: "{{ config('services.firebase.projectId') }}",
storageBucket: "{{ config('services.firebase.storageBucket') }}",
messagingSenderId: "{{ config('services.firebase.messagingSenderId') }}",
appId: "{{ config('services.firebase.appId') }}",
measurementId: "{{ config('services.firebase.measurementId') }}"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig); //getting error on this line
many answers i saw to reso;ve this issue were about include scripts that are already included i tried to include them in head too but not working i am working on local server
2
Answers
You use JS modules scripts, but you need to include compatibility libraries as mentioned here https://firebase.google.com/docs/web/modular-upgrade#window-compat
rename files
Firebase’s JavaScript SDKs support two syntaxes:
The code in your question uses a mix of these two syntaxes, which unfortunately isn’t possible. The good news is that you have two options to move forward: