You are tasked with ensuring that specific headers are added to every HTTP request in your Angular application. How would you achieve this?
- Create an HTTP interceptor
- Manually add headers to each request
- Modify the Angular configuration file
- Use a service to add headers
To ensure specific headers are added to every HTTP request, you should create an HTTP interceptor. Interceptors allow you to intercept outgoing requests and modify them, making it a suitable choice for adding headers uniformly to requests across your Angular application.
Loading...
Related Quiz
- Which module in Angular is primarily used for setting up routing?
- Which is NOT a lifecycle hook in Angular?
- What is the purpose of the ControlValueAccessor interface in Angular forms?
- In Ngxs, what is used to define metadata for state operations?
- You are working on a project where the client has specific linting rules. How can you modify the existing linting rules of an Angular CLI project?