July 2018
Intermediate to advanced
420 pages
8h 46m
English
Let's take a look at how to use Angular's HttpInterceptor interface to make authenticated HTTP requests.
When we are handling authentication in an Angular app, most of the time, it's generally best to put everything you need in a dedicated service, like we did previously.
Any authentication service should have a few basic methods for allowing users to log in and log out. It should also include a method for retrieving a JSON Web Token and putting it into localStorage (like we did previously), on the client, and a way to determine if the user is authenticated or not, in our case, using the isAuthenticated() function on auth.service.ts.
So, let's create the HTTP interceptor:
Read now
Unlock full access