1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Run an API multiple times and store the result in an array

Discussão em 'Angular' iniciado por Shashikumar N, Outubro 2, 2024.

  1. I want to run an API call multiple times and then store the API response in an array/observable.


    public getProgramNamesList() {
    for (let i = 0; i < this.totalPages; i++) {

    this.accountAdminApiService.getAccountAdminProgramsBySearch((i)).subscribe((programResults: ProgramSearchResults) => {
    if (programResults?.data?.length) {
    this.totalPages = Math.ceil(programResults.totalCount / this.pageSize);

    this.programResults$.next(programResults.data);
    }
    });
    }

    return this.programResults$;
    }

    I tried the above code. It is only returning the first set of results and the API is not running multiple times.

    Continue reading...

Compartilhe esta Página