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");
}

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.

Further reading

Problem with a question

Angular · Junior · question 48

Test yourself

Take the Angular · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz