Click here to Skip to main content
15,918,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have http request to get data from backend.
In the ts file, I have
public prj1: string[] = [];
public prj2: string[] = [];

ngOnInit() {

getProj1() {
   this.service['pj1'].get().subscribe(data => {
      this.prj1 = data;

getProj2() {
   this.service['pj2'].get().subscribe(data => {
      this.prj2 = data;

You don't have to know what is this.service
It works well, I do get the two string arrays. However I have many similar methods, I want to get all string arrays parallel. So I think that maybe rxjs can do it. I don't have the experience to use rxjs library. Please help me for this particular case.

What I have tried:

  let one= this.service['pj1'].get();
  let two= this.service['pj2'].get();

forkJoin([one, two]).subscribe(results => {
[no name] 29-Aug-19 9:08am    
No idea if it will work but you want to have a go anyway?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900