HTTP Client in Angular
From the Angular cheat sheet · HTTP & Observables · verified Jul 2026
HTTP Client
Making HTTP requests with HttpClient
typescript
// Register HttpClient at bootstrap: bootstrapApplication(App, { providers: [provideHttpClient()] })
import { provideHttpClient } from '@angular/common/http';
// Service with HTTP
@Injectable()
export class DataService {
constructor(private http: HttpClient) {}
getData(): Observable<Data[]> {
return this.http.get<Data[]>('/api/data');
}
postData(data: Data): Observable<Data> {
return this.http.post<Data>('/api/data', data);
}
}💡 Always handle errors with catchError operator
⚡ Use interceptors for cross-cutting concerns
📌 Set responseType for non-JSON responses
🔥 Use reportProgress for file upload progress