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

171
Views
SwitchMap not triggering second API call

The below angular code switchMap is not working, I'm not sure what error I made. Under the switchMap second API call not triggering '/upload/file'

zip(
  this.service.submitForm(formValue),
  this.service.upload(fData)
).subscribe(
  ([submitForm, upload]) => {
    if (submitForm === 'success' && upload === 'Ok') {
      //Redirect confirmation page
    }
  },
  (err) => {
    console.log(err, 'ERORORO');
  }
)

//Service code
upload(formData): Observable <any> {
  return this.sessionService.keepAlive().pipe(
    switchMap(data => {
      let token = data.jwtToken;
      console.log(token, 'TOKEN SESSION');
      // getting output as Bearer xyz
      // with formData as req
      const request_config = {
        headers: {
          "Authorization": token
        }
      };
      console.log("REQUEST CONFIG", request_config); // getting output
      return this.http.post < any > (
        '/upload/file',
        formData,
        request_config
      ).pipe( // this is not working
        map((res) => {
          console.log(res, 'RESPONSE');
          return res.status;
        }),
        catchError((error: HttpErrorResponse) => {
          throw error;
        })
      )
    })
  )
}
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!