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

107
Views
Angular Promise devuelve indefinido en otro componente

este es mi carComponent.ts tiene el siguiente método:

 async Download() { try { const settings = { kit: true, tyres: true, serviced: false, }; const [kits, tyres] = await Promise.all([ this.checkKits( conf, "A", 100, false, "My kit" ), this.checktyres(100, 50, false, 'My tyres'), ]); const checkSvg= [...kits.slice(0, 4), ...tyres, ...kits.slice(4)]; checkSvg.forEach(({ side, svg }) => { console.log(svg); // here it returns all the SVG data; works 100% return svg; }); } catch(e) { console.error(e); } }

esto es viewCarsComponent.ts que está llamando al método anterior. Pero aquí la promesa devuelve indefinido, ¿alguien puede ayudarme a resolver mi problema? No estoy seguro de qué estoy haciendo mal o qué debo hacer aquí para resolverlo.

 async DisplaySVG() { await this.carComponent.Download().then(data =>{ console.log(data); // here it is undefined... }).catch(error =>{ console.log(error) }); }

Gracias

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

0

Actualmente no tiene una declaración de devolución en Descargar, por lo que, de forma predeterminada, la promesa se resuelve como indefinida. Si desea devolver una matriz de todos los kits y neumáticos, simplemente devuelva checkSvg :

 const checkSvg = [...kits.slice(0, 4), ...tyres, ...kits.slice(4)]; return checkSvg;

Si cada uno de estos tiene una propiedad .svg , y solo los quiere, cree una nueva matriz con solo las propiedades .svg y devuelva eso:

 const checkSvg = [...kits.slice(0, 4), ...tyres, ...kits.slice(4)]; const svgsOnly = checkSvg.map(({ svg }) => svg); return svgsOnly;
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!