
Angular Http
- 182 installs
- 6 repo stars
- Updated April 4, 2026
- oguzhan18/angular-ecosystem-skills
Configure Angular HttpClient with interceptors, typed responses, error handling, and auth headers to call REST or GraphQL backends from services and resolvers safely.
About
angular-http documents Angular HttpClient usage—service injection, interceptors, typed Observables, error mapping, and auth headers—for connecting components to REST or GraphQL backends during feature development.
- HttpClient service injection patterns
- Interceptors for auth and errors
- Typed Observable response handling
- Retry and error surfacing strategies
- Pairs with environment base URLs
Angular Http by the numbers
- 182 all-time installs (skills.sh)
- +2 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #889 of 2,245 Frontend Development skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/oguzhan18/angular-ecosystem-skills --skill angular-httpAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 182 |
|---|---|
| repo stars | ★ 6 |
| Last updated | April 4, 2026 |
| Repository | oguzhan18/angular-ecosystem-skills ↗ |
What it does
Configure Angular HttpClient with interceptors, typed responses, error handling, and auth headers to call REST or GraphQL backends from services and resolvers safely.
Files
@angular/common/http
Version: Angular 21 (2025) Tags: HTTP, REST, API, Interceptors
References: HttpClient • API • Interceptors
API Changes
This section documents recent version-specific API changes.
- NEW: Functional interceptors — Use
provideHttpClient(withInterceptors([...]))for modern interceptor setup source
- NEW:
withFetch— Use native fetch API with HttpClient source
- NEW:
withInterceptorsFromDi— Legacy interceptor support with functional approach
- NEW: HttpContext tokens — Per-request metadata using HttpContextToken
- NEW:
AbortSignalsupport — Request cancellation with timeout support
- DEPRECATED: Class-based HttpInterceptor — Migrate to functional interceptors
Best Practices
- Use functional interceptors
// ✅ Modern functional interceptor
export const authInterceptor: HttpInterceptorFn = (req, next) => {
const authService = inject(AuthService);
const token = authService.getToken();
if (token) {
const authReq = req.clone({
setHeaders: { Authorization: `Bearer ${token}` }
});
return next(authReq);
}
return next(req);
};
// Register
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(withInterceptors([authInterceptor]))
]
};- Use interceptors for cross-cutting concerns — Authentication, logging, error handling
// Error interceptor with retry
export const errorInterceptor: HttpInterceptorFn = (req, next) => {
return next(req).pipe(
catchError((error: HttpErrorResponse) => {
if (error.status === 401) {
inject(Router).navigate(['/login']);
}
return throwError(() => error);
})
);
};- Use retry with backoff for flaky networks
import { retry, delay, catchError } from 'rxjs/operators';
http.get('/api/data').pipe(
retry({ count: 3, delay: 1000 })
);- Use HttpContext for per-request flags
const cacheToken = new HttpContextToken<boolean>(() => false);
export const cacheInterceptor: HttpInterceptorFn = (req, next) => {
if (req.context.get(cacheToken)) {
// Check cache
}
return next(req);
};
// Usage
http.get('/api/data', {
context: new HttpContext().set(cacheToken, true)
});- Use proper typing for HTTP responses
interface User {
id: number;
name: string;
}
http.get<User>('/api/user/1').subscribe(user => {
console.log(user.name); // TypeScript knows the type
});- Use
observe: 'response'for full HTTP response
http.get('/api/data', { observe: 'response' }).subscribe(response => {
console.log(response.headers);
console.log(response.body);
});- Handle errors globally
@Injectable()
export class GlobalErrorHandler implements ErrorHandler {
handleError(error: Error) {
// Log to error tracking service
console.error(error);
}
}
// Register
provideErrorHandler(GlobalErrorHandler)- Use
withCredentialsfor CORS requests
http.get('/api/data', { withCredentials: true });