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

114
Vistas
How can my code await the firebase responce before returning the object

My code works, and the console.log is showing the object, and if i go to my firebase console and change the data then it is updated in realtime.

However when initially direcred by my router to the PlaylistDetails.vue it is taking the empty fields and displaying them whilst my program talks to firebase, when data is returned the console prints but my fields are still blank.

im assuming i need to get an async await function in there somewhere, or v:bind

export default {
  props: ["id"],
  setup(props) {
    const db = getFirestore();
    const docRef = doc(db, "playlists", props.id);
    const playlist = { id: "", title: ""};

    const unsub = onSnapshot(docRef, (doc) => {
      playlist.id = doc.id;
      playlist.title = doc.data().title;
      console.log(playlist);
    });

    watchEffect((onInvalidate) => {
      onInvalidate(() => unsub());
    });

    return { playlist };
  },
};
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