0
votes

I have the following:

db.collection("users")
    .where("activated", "==", 0)
    .get()
    .then(snap => {
    snap.forEach(doc => {
        if (String(doc.data().profileURL) != String(defaultImageUrl)) {
            var r = document.getElementById('userTable').insertRow()
            r.insertCell(1).innerHTML = doc.data().age
            
            var storageRef = firebase.storage().ref();
            var temp_photo = storageRef.child('avatar/'+doc.data().profileURL+'/')
            temp_photo.getDownloadURL().then(downloadURL => {
                 console.log("log here -> " + downloadURL);
                var y = r.insertCell(2).innerHTML = '<img src="'+downloadURL+'" width="50" height="50" />';
            })
            }
        }
      }//closing braces might be off but the rest of the code works, just to this purpose
    });
});

All the data shows correctly, but the image doesn't show and the app crashes

[Error] Error: Cannot instantiate firebase-storage - be sure to load firebase-app.js first. (anonymous function) (firebase-storage.js:1:39246) (anonymous function) (firebase-storage.js:1:165) Global Code (firebase-storage.js:1:188) [Error] Unhandled Promise Rejection: TypeError: firebase.storage is not a function. (In 'firebase.storage()', 'firebase.storage' is undefined) (anonymous function) (toActivate.js:39) (anonymous function) (firebase-firestore.js:1:278233) (anonymous function) (firebase-firestore.js:1:64792) (anonymous function) (firebase-firestore.js:1:58068) (anonymous function) (firebase-firestore.js:1:58062) (anonymous function) (firebase-firestore.js:1:58062) (anonymous function) (firebase-firestore.js:1:58062) (anonymous function) (firebase-firestore.js:1:64769) (anonymous function) (firebase-firestore.js:1:278214) (anonymous function) (toActivate.js:20) promiseReactionJob

In my html i do have the storage script:

<script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-firestore.js"></script>
    <script src="https://www.gstatic.com/firebasejs/7.2.3/firebase-storage.js"></script>
1

1 Answers

1
votes

The versions of your Firebase scripts need to all match. Your firebase-storage does not match firebase-app. According to the release notes, latest version is 7.23.0.