Unable to retrieve Firebase downloadURL from .getDownloadURL() promise


Jean-Marie Damaso

I'm trying to retrieve the downloadURL from an image I've uploaded to Firebase. It's no problem getting the correct URL in the promise.

I don't understand why downloadURL is still not defined after setting downloadURL equal to the url returned in the .then statement.

let downloadURL;

    firebase
      .storage()
      .ref()
      .child('project_images/' + imageName)
      .getDownloadURL()
      .then(url => {
        downloadURL = url;
        console.log(downloadURL); //logs the correct downloadURL needed
      })
      .catch(error => {});

    console.log(downloadURL); //still undefined

I feel like I'm missing something stupid, but for the life of me I can't see what it is. Any help is appreciated. Thanks!

Jordan

Does it document undefinedthe one in the promise?

Probably just not fulfilling the promise before trying to log outside of the function call.

Related


Unable to get URL from Firebase's getDownloadURL

Stern Shaw: I'm using Firebase storage to store images into it, the images are easily uploaded to the storage, but when I try to get the url of the image form Promise, it doesn't return any url. const imageSaveHandler = (e) => { e.preventDefault(); c

Unable to get URL from Firebase's getDownloadURL

Stern Shaw: I'm using Firebase storage to store images into it, the images are easily uploaded to the storage, but when I try to get the url of the image form Promise, it doesn't return any url. const imageSaveHandler = (e) => { e.preventDefault(); c

Unable to get URL from Firebase's getDownloadURL

Stern Shaw: I'm using firebase storage to store images into it, the images are easy to upload to the storage, but when I try to get the url of the image form Promise, it doesn't return any url. const imageSaveHandler = (e) => { e.preventDefault(); co

Unable to retrieve image from Firebase

Samsul Islam | I'm trying to build a messenger type app. For this, I have uploaded the image from my phone to Firebase. The image is successfully stored in Firebase Storage. I am trying to display an image on my phone. I'm using both Picasso and Glide to retri

Unable to retrieve image from Firebase

Samsul Islam | I'm trying to build a messenger type app. For this, I have uploaded the image from my phone to Firebase. The image is successfully stored in Firebase Storage. I am trying to display an image on my phone. I'm using both Picasso and Glide to retri

Unable to retrieve Int from Firebase

Batuhan I'm trying to retrieve an Int from Firestore, but I can't say "The result of a call to 'append' is unused" Here is my code: class pointsM: ObservableObject { @Published var point = 0 init() { let db = Firestore.firestore() let user = Auth.auth(

Unable to retrieve image from Firebase

Samsul Islam | I'm trying to build a messenger type app. For this, I have uploaded the image from my phone to Firebase. The image is successfully stored in Firebase Storage. I am trying to display an image on my phone. I'm using both Picasso and Glide to retri

Unable to retrieve image from Firebase

Samsul Islam | I'm trying to build a messenger type app. For this, I have uploaded the image from my phone to Firebase. The image is successfully stored in Firebase Storage. I am trying to display an image on my phone. I'm using both Picasso and Glide to retri

Unable to retrieve image from Firebase

Samsul Islam | I'm trying to build a messenger type app. For this, I have uploaded the image from my phone to Firebase. The image is successfully stored in Firebase Storage. I am trying to display an image on my phone. I'm using both Picasso and Glide to retri

promise.all use getDownloadURL() in firebase

New cat I'm struggling to get the download image URL in Firebase Storage. What I want to achieve with this code is to upload two images one after the other and then push the image URLs into an array. However, my code doesn't work properly as async. The result

promise.all use getDownloadURL() in firebase

New cat I'm struggling to get the download image URL in Firebase Storage. What I want to achieve with this code is to upload two images one after the other and then push the image URLs into an array. However, my code doesn't work properly as async. The result

promise.all use getDownloadURL() in firebase

New cat I'm struggling to get the download image URL in Firebase Storage. What I want to achieve with this code is to upload two images one after the other and then push the image URLs into an array. However, my code doesn't work properly as async. The result

promise.all use getDownloadURL() in firebase

New cat I'm struggling to get the download image URL in Firebase Storage. What I want to achieve with this code is to upload two images one after the other and then push the image URLs into an array. However, my code doesn't work properly as async. The result

Unable to retrieve data from Firebase in Django

Ansel D'souza: I've been trying to get data from Firebase into my Django app and the problem I'm facing is that some documents are being retrieved and some are not. One very strange thing I've noticed is that on the admin page, the documents that are accessibl

Unable to retrieve data from Firebase database

Vishal I have a Firebase database as shown. I'm trying to retrieve data based on some criteria but it's not showing any results. DbRef2 =FirebaseDatabase.getInstance().getReference().child("Notification"); DbRef2.child("45961").orderByChild("FromId").

Unable to retrieve data from Firebase in Django

Ansel D'souza: I've been trying to get data from Firebase into my Django app and the problem I'm facing is that some documents are being retrieved and some are not. One very strange thing I've noticed is that on the admin page, the documents that are accessibl

Unable to retrieve data from Firebase database

Naga Hermans Here is my component. I don't know why the data cannot be retrieved from Firebase. Can anyone tell me what's wrong in this code? import { Component, OnInit, Input, ViewChild } from '@angular/core'; import { AngularFireDatabase, FirebaseListObserva

Unable to retrieve list of documents from Firebase

Yuval I'm trying to retrieve a list of documents using the admin SDK and firestore api on my firebase functions. I try to use the following method: import * as admin from 'firebase-admin'; const adminFirestore = admin.firestore(); adminFirestore.collection

Unable to retrieve data from Firebase database

Vishal I have a Firebase database as shown. I'm trying to retrieve data based on some criteria but it's not showing any results. DbRef2 =FirebaseDatabase.getInstance().getReference().child("Notification"); DbRef2.child("45961").orderByChild("FromId").