Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have following http interceptor in my angular app:
import { Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpResponse } from '@angular/common/http';
import { HttpRequest } from '@angular/common/http';
import { HttpHandler } from '@angular/common/http';
import { HttpEvent } from '@angular/common/http';
import { tap } from 'rxjs/operators';
import { SpinnerService } from '../sharedServices/spinner.service';
@Injectable()
export class CustomHttpInterceptor implements HttpInterceptor {
constructor(private spinnerService: SpinnerService) { }
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
this.spinnerService.show();
return next.handle(req)
.pipe(tap((event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
this.spinnerService.hide();
}, (error) => {
this.spinnerService.hide();
in the line I used
I get this warning:
Instead of passing separate callback arguments, use an observer
argument. Signatures taking separate callback arguments will be
removed in V8
the code is working but I see a strike on "tap" keyword alongside above warning
(event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
this.spinnerService.hide();
(error) => {
this.spinnerService.hide();
Do this:
tap({
next: (event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
this.spinnerService.hide();
error: (error) => {
this.spinnerService.hide();
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.