THEN ARRAY EMPTY PROMISSE : <p>Create a method to fetch time in the firestore by calling the promise, but the array comes empty because the promise has not yet been resolved. How to resolve to call the array only when a getTime () call terminates.</p>

<p>Angular Cli 8</p>

<pre><code>example.service.ts

teste: [];

getTime() {
    this.userCollection.ref.get()
      .then(res =&gt; {
        if (res.docs.length == 0) {
          alert('Não existem marcacoes até o momento por favor aguarde')
        } else {
          res.forEach(ponto =&gt; {
            console.log(ponto.id);
            console.log(ponto.data().time.seconds * 1000);
            this.time.push(new Date((ponto.data().time.seconds * 1000)));
          })
        }
      }).catch(err =&gt; {
        console.log(err);
      })
  }
</code></pre>

<pre><code>example.component.ts

ngOnInit() {
    this.mainService.getTime();
    console.log(this.mainService.time);
  }
</code></pre>

<p>I hope the array variable is already complete when I call it.</p>
