1

Basically, I want to check if a file exists on a specific location on FB Storage If so then, do some Stuff else some other stuff needs to be executed.

so far I have tried this

const profile_pic = firebase.storageRef
        .child(`profile_pics/${uid}/}`)
        .getDownloadURL()
        .then((url) => {
          setProfileImage(url);
        })
        .catch((err) => {
          // show Default userPic    
          console.log("err >> ", err);
        });

This code Resembles the answer here

This Code works Fine BUT BUT BUT It still logs Error on the console. enter image description here

All I'm Looking for is the best way to get it done without logging Error On console. Any help is Appreciated! Thanks.

mr noob
  • 345
  • 2
  • 14
Lalit Vavdara
  • 406
  • 4
  • 9
  • You tagged with `node.js` and with `reactjs`, but the code seems to be using the regular [Firebase JavaScript SDK for accessing Cloud Storage](https://firebase.google.com/docs/reference/js/firebase.storage). I updated the tags to reflect this. If the Node.js or React.js tag *is* relevant to the problem, feel free to add it back **and clarify why it's relevant in the question. – Frank van Puffelen Jan 24 '21 at 19:14
  • No I think both were Irrelevant Tags... I just Added them coz I was using that tech stack for better understanding, thanks anyway :) – Lalit Vavdara Jan 24 '21 at 20:01

1 Answers1

0
const profile_pic = firebase.storageRef
        .child(`profile_pics/${uid}/}`)
        .getDownloadURL()
        .addOnSuccessListener(new OnSuccessListener(){

        {
          setProfileImage(url);
        })
          .catch((err) => {   
           console.log("err >> ", err);
        }

        });

Try this

ADITYA RANADE
  • 293
  • 3
  • 10
  • as expeced I got this err --> ```MapboxGl-MAP.js:65 Uncaught TypeError: _Firebase_Fbase__WEBPACK_IMPORTED_MODULE_5__.default.storageRef.child(...).getDownloadURL(...).addOnSuccessListener is not a function at get_coords (MapboxGl-MAP.js:65) at MapboxGl-MAP.js:296 at invokePassiveEffectCreate (react-dom.development.js:23487)``` – Lalit Vavdara Jan 25 '21 at 19:34
  • you are using java/javascript to code right ? – ADITYA RANADE Jan 26 '21 at 11:06
  • yup.. I'm using JavaScript – Lalit Vavdara Jan 27 '21 at 12:36