From the course: Building Applications with Angular, ASP.NET Core, and Entity Framework Core

Unlock the full course today

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

Update Angular service to post to API

Update Angular service to post to API

From the course: Building Applications with Angular, ASP.NET Core, and Entity Framework Core

Start my 1-month free trial

Update Angular service to post to API

- [Narrator] In this video, we'll get our front end, to communicate with our back end post question end point. The first thing we'll do is get the URL. So let's hit play, and we can copy that from the browser. Let's copy the URL, and then go back to our front end. Inside our front end project, let's open up our apiservice.ts And on line ten, let's paste in our URL. Then we'll update values to questions. So now that we've updated our URL, next let's go to our question component. And instead of console logging our question, we'll call our api service post question. But first we'll need reference to it so let's create a constructor. And we'll need to import it. And of course, we'll need to register it with our app module. So I'll copy the import, paste it at the top on line 8. And then in our providers list on line 23, we'll add api service. Then let's set the body of our constructor. And now on line 13, let's call this.api.postquestion and we'll pass in our question. Let's save that and…

Contents