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

92
Views
Cómo fusionar dos resultados de matriz Api en uno en angular

Los primeros resultados de mi matriz api son los siguientes:

 {name: 'ABC', state: 'AR', licenseNumber: '100108512'} {name: 'DEF', state: 'KY', licenseNumber: '100108518'}

Los resultados de mi segunda matriz api son los siguientes:

 {rollnum: '20' name: 'KGF', state: 'NE', licenseNumber: '1628740'}

Me gustaría ver la salida como a continuación

 {name: 'ABC', state: 'AR', licenseNumber: '100108512'} {name: 'DEF', state: 'KY', licenseNumber: '100108518'} {name: 'KGF', state: 'NE', licenseNumber: '1628740' }

Probé la sintaxis concat y spread, pero no funcionó porque la 1.ª api tiene 3 propiedades y la 2.ª api tiene 4 propiedades (pero 3 propiedades son comunes en ambas).

¿Alguna sugerencia para lograr el resultado anterior en Angular 9 o superior?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Solo mapea y concatena:

 // example let first = [{ name: 'ABC', state: 'AR', licenseNumber: '100108512' }, { name: 'DEF', state: 'KY', licenseNumber: '100108518' }]; // example let second = [{ rollnum: '20', name: 'KGF', state: 'NE', licenseNumber: '1628740' }]; // use this common function to map the results in each set to the desired shared outcome // if you have different logic or properties for mapping (eg map FirstName to Name) then make different mapping functions or change mapping logic in same function. let mappingFunc = (item) => { return { name: item.name, state: item.state, licenseNumber: item.licenseNumber }; }; // final result contains desired result const finalResult = first.map(mappingFunc).concat(second.map(mappingFunc)) console.log(finalResult);

about 4 years ago · Santiago Gelvez 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!