Angular ssr, server doesn't wait api calls for the first time?

Viewed 130

I have Angular 9+ ssr app.

In ngOnInit I load tournaments and show them in the table-component.

Everything works fine but if I use an incognito tab and then visit my site for the very first time tournaments in returned html is empty, but then if I refresh the page tournaments in returned html is correct.

I think that, for the first time server doesn't make Api calls at all or doesn't wait responses.

Any solution for this issue?

tournaments.components.ts

  ngOnInit(): void {
    this.getPokerTournaments();
  }

  getPokerTournaments() {
    this.pokerTournamentsLoading = true;
    this.pokerService.getPokerTournaments().subscribe(
      (res) => {
        this.pokerTournaments = res;
        this.pokerTournamentsLoading = false;
      },
      (err) => {
        this.pokerTournaments = [];
        this.pokerTournamentsLoading = false;
      }
    );
  }
0 Answers
Related