# HttpClient Basics — Angular

Source: https://www.geekswithgeeks.com/en/angular/ng-httpclient

> Call a backend API from a service.

## Enabling it

`provideHttpClient()` registers `HttpClient` so it can be injected anywhere in the app.

```typescript
// main.ts
bootstrapApplication(AppComponent, {
  providers: [provideHttpClient()],
});
```

## A GET request

`HttpClient.get<T>()` returns an Observable — nothing happens until something subscribes to it.

```typescript
@Injectable({ providedIn: 'root' })
export class ProductService {
  private http = inject(HttpClient);

  getProducts() {
    return this.http.get<Product[]>('/api/products');
  }
}
```
