Hi guys, in this lesson we will implement user service in user service. We will call user operations from user micro service with HTTP request and headers. To do it, we will create services folder under main source folder. Under services, we will create user service class. class name will be user service, and user service will be exported as user service in default mode. When we describe it as default, this means the other components can import it without using braces to get Post REST API request in user service, we should import axios module.
Then we will describe our API euro. Our API URL will be gateway user service. Our second variable will be current users subject and current user subject we will leave behavior subject. Later we will import behavior subject module because we will serve current user as a sacrum. We will use it to subscribe current user, we can create current user subject from local storage current user really. Okay now we can create our methods.
Our first method we will be to get current user value. We will return current user subject video as result. Our second method will be to get current users. We will use current user as observable from current user subject, because we will call it from other components and we will use it to reactively update when a user logs in or log out if we don't use us Vertical, the fields on other components will be immutable. Our third methods will be logging, we will send a get request to server side with predefined REST API. In this method, login authentication will be provided with HTTP header and authentication header will be encrypted.
Because we want to secure authentication. Normally, we can send credentials with API path, like API logon, username, blah, blah, blah, and password blah, blah, blah, you know that it is not a secure way. Everybody can see these parameters easily. When we send credentials with HTTP header, only c brain can understand because we will use spring security on server side. Our login REST API path is enabled. UI user service login after login we will store the result of it in local storage and we will subscribe it Our first method will we log out, we will send POST requests to server side with predefined REST API, our logout REST API Patty's API user service logout After logout, we will remove result of it from local storage, and we will unsubscribe it.
Our last methods will be register. To register. We will send post request to server side with predefined REST API, our registration REST API that is API users service registration and we will send data with Jason Okay, that's all about user service implementation. Thank you.