From the course: Angular: API Communication and Authentication

Unlock the full course today

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

Wrapper functions for GET, POST, PUT, and DELETE

Wrapper functions for GET, POST, PUT, and DELETE - Angular Tutorial

From the course: Angular: API Communication and Authentication

Start my 1-month free trial

Wrapper functions for GET, POST, PUT, and DELETE

- [Instructor] Now that we have our main request function, providing wrapper functions to make Get and Post requests is now much easier. The Get method on our API service will simply take in a string for the URL. Here, we will simply return the result of calling the request method with the URL and the Get method. That will be RequestMethod.Get. The Post method on our API service will take in a string, and the body, which is a payload, we will be posting to our API. Here we will return the result of calling the request method with the URL, Method.Post in the body. We can go ahead and also provide helper methods for Put and Delete, in case we need them in the future. Like Post, Put also takes in a body, and delete only takes in a URL. Our API service is shaping up really nice.

Contents