Reputation: 629
I'm new to web development and firebase and a error is appearing to me. I've not been able to solve it so came here to seek for help.
The error displayed is firebase.storage() is not a function
. It seems that the firestorage is not set correctly in my computer. However, I've followed the instructions download from the google website itself and it did not change a thing.
I've seen some other questions regarding this on Stack Overflow, but they use node or react which is not my case. Can someone give me a hint?
I know it is not explained in details because, as I said before, I'm not an expert. Please be compreensive and I'll develop better my question.
The code I've created is bellow. The first block is a subset of an .html file. The other one is the body of my .js file
<!-- Firebase App is always required and must be first -->
<script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-app.js"></script>
<!-- Add additional services that you want to use -->
<script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-messaging.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-functions.js"></script>
<!-- Inicializa o firebase -->
<script>
var config = {
apiKey: "..",
authDomain: "..",
databaseURL: "..",
projectId: "..",
storageBucket: "..",
messagingSenderId: "..",
appId: ".."
};
firebase.initializeApp(config);
</script>
<!-- Nosso app -->
<script src="./app.js"></script>
var fileInput = document.getElementById('file-input');
var stringInput = document.getElementById('string-input');
var ref = firebase.storage();
fileInput.onchange = function (event) {
}
stringInput.onchange = function (event) {
}
Upvotes: 5
Views: 10520
Reputation: 4672
You need to include the firebase storage api.
You can do this by adding this line after you import the firebase-app
script:
<script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-storage.js"></script>
You can see a demo in this code sandbox: https://codesandbox.io/s/vqy01k5175
Upvotes: 22