Authorizing HTTP Requests

Learn how to add authentication tokens in HTTP request headers.

The Fake Store API does not require authorization while communicating with its endpoints. However, consider that we are working with a backend API that expects all HTTP requests to contain an authentication token using HTTP headers. A common pattern in web applications is to include the token in an Authorization header.

Streamlining HTTP requests with custom headers

We can use HTTP headers in an Angular application by importing the HttpHeaders artifact from the @angular/common/http namespace and modifying our methods accordingly:

Get hands-on with 1200+ tech skills courses.