Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda