From the course: Building Angular and ASP.NET Web API Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Requesting data from Web API

Requesting data from Web API

From the course: Building Angular and ASP.NET Web API Apps

Start my 1-month free trial

Requesting data from Web API

- [Instructor] So far, we have created the first action, the first controller which will return some data. Then, we created our first component and the service. Now, it is time to create our first method of our service. When you create a method inside a service, which will be used to get some data from the Web API Endpoint, you need to first create the method, then inject the service in your component from where you want to call the method, and then call the method. So, let us go and create our first service. For that, go to the entry.service.ts file and inside the entry service class, create your first method. You are going to name the first method getAll because this method is going to be used to get all the entries from the database. But since we are sending an http request, we need to inject the http client. So, for that, inside the constructor, write private http: and then HttpClient. Let us import the http client. For that, we just write in here import {HttpClient} from…

Contents