Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda