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

144
Views
RxJs: merge stream data and a promise

I would like to display users's data and their profile pictures. But I get the basic data and the profile pictures from 2 different services. What I would like to do, is to merge the pictures' url into my tableData.

My code so far:

interface User {
  id: number,
  name: string,
  email: string
}

interface UserWithPicture extends User {
  image: string[] | "",
}

interface ProfileImage {
  id: number,
  url: string
}

  tableData: UserWithPicture[];
  profileImage: ProfileImage[];

Both async functions return array of objects.


async ngOnInit() {
  this.tableData = await this.getUserDataService.fetchUsers().toPromise();
  const userID = this.tableData.map(u => u.userId);

  from(this.userProfilService.getUserProfileImage(userID))
    .pipe(takeUntil(this.destroy$),
      map(userProfileImages => userProfileImages.filter(user => user.id).map(upi => upi.url)))
    .subscribe(data => {
        this.userProfileImage = data;
      }
    })
}

I have tried to add the urls into tableData, but I cannot do that outside the relevant code block, it will always return undefined.

const newArr = this.tableData.map(v => Object.assign(v, {image: this.userProfileImage}))

How can I merge this.userProfileImage into the tableData object of arrays?

about 4 years ago · Juan Pablo Isaza
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!