[javascript] code_firebase

Viewer

copydownloadembedprintName: code_firebase
  1.  useEffect(async() => {
  2.         const getGymImages = async() => {
  3.             const store_image_ref = ref(storage, `gs://fit-user-app/store_images/jP6AalbtPcjk0Lbcxo5q`);
  4.             const fileReaderInstance = new FileReader();
  5.             await list(store_image_ref).then(function(result) {
  6.                     result.items.forEach(async function (imageRef) {
  7.                         // And finally display them
  8.                         console.log(await getDownloadURL(imageRef));
  9.                     })
  10.                 }).catch(function(error) {
  11.                     // Handle any errors
  12.                 });
  13.                     /*
  14.                 fileReaderInstance.readAsDataURL(await (store_image_ref)).then(
  15.                     (x) => {
  16.                         
  17.                         fileReaderInstance.onload = () => {
  18.                             base64data = fileReaderInstance.result;                
  19.                             setFitImage(base64data);
  20.                         }
  21.                     }
  22.                 )
  23.                 */
  24.         }
  25.         getGymImages()
  26.     }, []);
  27.  
  28.  
  29.     useEffect( async() => {
  30.         const loadData = async() => {
  31.             let fit_data = []
  32.             db.collection('fitness_centres').get()
  33.             .then(snapshot => {
  34.                 snapshot.forEach(doc=> async function(){
  35.                     const data = doc.data();
  36.                     data.id = doc.id
  37.                 })
  38.             }).then(function(){
  39.                 setFitness(fit_data)
  40.                 setLoadedFitness(true)
  41.             }
  42.             ).catch(err => alert(err))
  43.             
  44.         }
  45.         if (fitness.length == 0){
  46.             await loadData()
  47.         }
  48.     }, [])

Editor

You can edit this paste and save as new:


File Description
  • code_firebase
  • Paste Code
  • 21 Sep-2022
  • 1.71 Kb
You can Share it: