- In an HR webapp I have a list of candidates that are rendered to the DOM.
- Each one does either have a CV in Firebase Storage or not. Thus I need to determine which button I should display: 'Download CV' or 'Upload CV'.
- To check this, I am calling .getDowloadURL() on the file ref.
- If a CV is found, the 'Download CV' button is displayed, and everything is fine
- If nothing is found, an error is returned
- I then catch this error and handle it to display the "Upload CV" button on the DOM
My problem is that I still get 404 errors in the console for each candidate that does not have a CV. (I have also tried with onResolve, onReject, but the problem is the same).
I am very thankful for any hint!
This is my code:
firebase.storage().ref().child('cvs').child(doc.id).child('CV').getDownloadURL()
.then(function (url) {
document.getElementById('dwlCvBtn' + doc.id).classList.remove('d-none')
}).catch(function (error) {
// A full list of error codes is available at
// https://firebase.google.com/docs/storage/web/handle-errors
switch (error.code) {
case 'storage/object-not-found':
document.getElementById('uploadCvBtn' + doc.id).classList.remove('d-none')
break;
case 'storage/unauthorized':
// User doesn't have permission to access the object
break;
case 'storage/canceled':
// User canceled the upload
break;
case 'storage/unknown':
// Unknown error occurred, inspect the server response
break;
}
});