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

137
Views
Problema asíncrono dentro del interceptor angular

Tengo un interceptor que verifica si una condición es verdadera, abre una barra de bocadillos y espera a que el usuario haga clic en un botón (así que suscríbase al evento del observador del botón). Si es falso: devuelve la petición.

 intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { if (this.rightsService.actualCookies && this.cookiesService.get('cookie') !== this.rightsService.actualCookies) { const snackBarRef = this.snackBar.open('Session expired', 'refresh'); snackBarRef.onAction().subscribe(() => { window.location.pathname = window.location.pathname.split('/')[0] }); } else { return next.handle(req); } }

Mi problema es que si la condición es verdadera, el interceptor no espera el observable y creo que devuelve una respuesta void . es por eso que otros interceptores reciben un error:

Cannot read property 'pipe' of undefined

en línea

 intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> { return next.handle(request).pipe(

Mi pregunta es cómo deshabilitar el interceptor para devolver un valor si (this.rightsService.actualCookies && this.cookiesService.get('cookie') !== this.rightsService.actualCookies) es true

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

0

su interceptor DEBE devolver algo:

 intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { if (this.rightsService.actualCookies && this.cookiesService.get('cookie') !== this.rightsService.actualCookies) { const snackBarRef = this.snackBar.open('Session expired', 'refresh'); // angular will subscribe. do whatever you need to do in tap. return snackBarRef.onAction().pipe(tap(() => { window.location.pathname = window.location.pathname.split('/')[0] })); } else { return next.handle(req); } }
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!