Example of consuming RESTful Spring web APIsÂ
In this section, you will learn about the different aspects of consuming Spring web APIs from custom Angular components and services, while demonstrating the user login functionality. The following will be illustrated:
- Spring RESTful API for user login
- Custom Angular component for managing login view
- Custom Angular service for serving login functionality
Spring RESTful API for user login
In order to serve user login functionality from the server end, the following server-side components need to be developed:
- RESTful controller exposing login API: The following is the code for
@RestController
serving the login API. The details around this is explained in one of the earlier sections. The login form, when submitted, are processed within the Angular component,LoginComponent
, which invokes an API of a custom Angular data service such asLoginService
. TheLoginService
API sends a POST request to the Spring RESTful API such ashttp://localhost:8080/account...