I am upgrading from the HttpServer to the HttpClientService and as part of that I have to switch my headers from Headers to HttpHeaders. However For some reason my custom headers are no longer being appended. What do I need to update to have the headers appended?
private getHeaders(headers?: HttpHeaders): HttpHeaders {
if (!headers) {
headers = new HttpHeaders();
}
headers.delete('authorization');
const token: any = this.storageService.getItem('token');
if (token) {
headers.append('Authorization', 'Bearer ' + token);
}
const user: User = this.storageService.getObject('user');
if (user && Object.keys(user).length) {
headers.append('X-Session-ID', user.uuid);
headers.append('X-Correlation-ID', this.uuidService.generateUuid());
}
return headers;
}
That method returns a httpHeader but it's empty.