Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
How to execute another observable based on array from result returned from another one

I have a quite simple situation but i got stuck. I have function customGalleriesHttpService.list() which returns observable with array of items. Lets assume:

[
{id:1,
... other stuff
},
{id:2,
... other stuff
}
]

Now I want to take each element from this array and make an extra http request customGalleriesHttpService.images(data.id) which returns observable with array of images for particular elemend based on his id. What i achived so far.

    this.customGalleriesHttpService.list().pipe(
      concatMap((data) => data),
      mergeMap((data) => this.customGalleriesHttpService.images(data.id)),
    ).subscribe((data) => console.log(data));

it is working but there is on more thing. It gives me output like this:

Array[6], Array[6]

what i want to achive is to group this and return [Array[6], Array[6]]

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Add a toArray() operator before subscribe should work

this.customGalleriesHttpService.list().pipe(
  concatMap((data) => data),
  mergeMap((data) => this.customGalleriesHttpService.images(data.id)),
  toArray(), 
).subscribe((data) => console.log(data));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!