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

118
Vistas
Why doesn't it finish executing the function completely?

I'm new to programming and I'm doing a university project with Vuejs in which I have to create a website with the use of an API (i'm using google books) and google firestore in which i want to store the 'id' of the books that are setted as "favorite" from the user.

I want to execute the function load() when the page is loaded, the problem is that the function stop to execute itself after the execution of console.log("var favs", favs) that is:

    var favs 
    [0: {id: '4dvptppOG8MC'},
     1: {id: '9CJWTbd-RYoC'},
     2: {id: 'HdRNzQEACAAJ'},
     3: {id: 'ayOd_Lu7m_MC'},
     4: {id: 'tp9svQEACAAJ'},
    ] 

But i'd like to have something printed per line, in a separeted way and not like an array, because, after, I've to compare each 'id' with another variable.

This is the code:

    created: function () {
            this.load();
          },
    
      methods: {
        load() {
          var favs = [];
          favs = DataService.getFav();
          console.log("var favs", favs);
          favs.forEach((item) => {
            console.log("item.id: ", item.id);
          });
        },

I don't know if it could be useful but this is the code of DataService.getFav()

      getFav: function () {
        var username = localStorage.getItem("username");
        var colName = username + "fav";
        var favs = [];
        db.collection(colName)
          .get()
          .then((response) => {
            response.forEach((doc) => {
              favs.push(doc.data());
            });
          });
        return favs;
      }
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