Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
Accesing the promise return value inside another function

I have a following function that uploads an image:

const uploadImage = async () => {
const storageRef = ref(storage, `${user.uid}/${imageName}`);
uploadBytes(storageRef, image).then((snapshot) => {
  console.log("Uploaded a blob or file!");
  getDownloadURL(snapshot.ref).then((downloadURL) => {
    console.log("File available at", downloadURL);
    return downloadURL;
  });
});};

I want to access the returning value from it inside another function, but it just returns undefined:

const anotherFunc = () => {
console.log(uploadImage()) // I want it to log the value of downloadURL, but instead it logs "undefined"

What I've tried:

  • making anotherFunc async and tried accesing value using await uploadImage
  • accesing value using .then()

Per my understanding, the function uploadImage returns a promise, because it's an async function. I guess I'm trying to access the value before the promise resolves? But still it doesnt work even with await. Can't quite wrap my head around promises yet. Any help is very appreciated, thanks in advance!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda