PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Angular · Theory

HTTP Interceptors

← All stacks

Theory

33/43

HTTP Interceptors

An interceptor sits on every HTTP call. Add an Authorization header. Log errors. Retry once. Provide it with withInterceptors or HTTP_INTERCEPTORS.

Board: clone the request, set Bearer token from auth, pass to next. If 401, navigate to login. Trap: intercepting and forgetting to call next.handle — the request never leaves.

Exam tip

Add token + 401 → login. Must call next.

Example

import { Component } from "@angular/core";

@Component({
  selector: "app-root",
  template: `
    <h1>{{ title }}</h1>
    <button (click)="toggle()">Toggle</button>
    <p *ngIf="open">Panel open</p>
  `,
})
export class AppComponent {
  title = "Angular practice";
  open = true;
  toggle() {
    this.open = !this.open;
  }
}

HTTP Interceptors: toggle open. Say whether the panel is on screen after one click.

Short notes

  • DefWrap every HttpClient call.
  • RuleClone request, then next.handle.
  • TrapDropping next / forgetting provide.

Questions

1

What is an HTTP interceptor for?

Previous← Router AdvancedNextForms Advanced →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.