Authentication Service

Let’s learn to create the necessary services that provide authentication for the whole application.

We'll cover the following...

Many approaches can be used to integrate the API into the frontend, but the ones that we chose will depend on the scale of our project. For our purposes, it’s better to isolate the API integration and transfer it to the application components using abstract services.

Services

The services approach scales exceptionally well with different applications and makes those same applications easier to maintain and debug. In the existing services directory, we’ll create these three files:

  • The services/auth.header.js file handles the common header that must be presented in all HTTP requests.
  • The services/auth.service.js file handles authentication services, such as sign-up, login, and logout.
  • The services/user.service.js file handles any other service related to the user profile, such as uploading a
...