From the course: Angular: API Communication and Authentication
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Wrapper functions for GET, POST, PUT, and DELETE - Angular Tutorial
From the course: Angular: API Communication and Authentication
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.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.