Get and subscribe

When you return to the code, we can see that we use the HttpClient class by calling two consecutive methods: .get<Quiz[]>() and .subscribe(). The former, as the name suggests, issues a standard HTTP request to our .NET Core QuizController to fetch an array of quizzes; we use a local string variable to assemble the controller's endpoint URL and then toss it as a parameter. The latter instantiates an Observable object that will execute two very different actions right after a result and/or in case of an error. Needless to say, all this will be done asynchronously, meaning that it will run in a separate thread (or scheduled for later execution), while the rest of the code continues to execute.

It's very important to understand ...

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.