Angular · Junior · Question 48 of 75
How do you make an HTTP GET request in Angular?
private http = inject(HttpClient);
getUsers() {
return this.http.get<User[]>("/api/users");
}- ✓Correct answer: With
HttpClient, which returns an Observable; the request is sent onsubscribe - 2With
HttpClient, which returns a Promise and sends the request immediately - 3Only with the browser
fetchfunction
Explanation
Register the client with provideHttpClient(). HTTP Observables are cold: nothing happens until something subscribes (manually or via the async pipe), and each subscription sends a new request.