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

178
Views
Spring y Angular: cómo hacer dos llamadas http una tras otra con una condición

Tengo una interfaz Angular que maneja la carga de un archivo, después de un botón de envío, persiste este archivo en la base de datos MySQL. Quiero hacer otra llamada dentro de este método de envío, pero la segunda llamada http necesita que la id de esa entidad persista (archivo) y no sé cómo recuperar esa identificación específica de ese archivo cargado.

este es mi método de envío:

 onSubmit() { const statementFile = new StatementFile(); // ******* // here are some business logic // ******* // this will send POST request and save it to MySQL. this.statementFileService.postStatementFile(statementFile).subscribe( { next : (response) => { alert('You have been submitted your statement file, check MySQL'); }, error: (err) => { alert(`there was a problem: ${err.message}` ); } } ); // this is the second http request I want to call but it needs particularly the id of that statementFile uploaded. this.activitiWorkflowService.createPreccess(statementFile.statementFileId).pipe(takeUntil(this._unsubscribeAll), debounceTime(3000)).subscribe( (data: any) => data ); }

esta es mi clase StatementFile:

 export class StatementFile{ statementFileId: number; dateReception: Date; label: string; }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar el operador switchMap para encadenar solicitudes. statementFile.statementFileId o response.statementFileId o algo más de la solicitud postStatementFile que usará para llamar a la siguiente solicitud.

 this.statementFileService.postStatementFile(statementFile) .pipe( switchMap(response => this.activitiWorkflowService.createPreccess(statementFile.statementFileId).pipe(takeUntil(this._unsubscribeAll))) ) .subscribe({ next : (data: any) => data, error: (err) => { alert(`there was a problem: ${err.message}` ); } } );
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!