Angular HttpClient append headers to HttpHeaders [duplicate]

HttpHeaders.append returns a clone of the headers with the value appened, it does not update the object. You need to set the returned value to the headers.

angular/packages/common/http/src/headers.ts

append(name: string, value: string|string[]): HttpHeaders { 
  return this.clone({name, value, op: 'a'}); 
} 

So to append the headers you do this.

let headers: HttpHeaders = new HttpHeaders();
headers = headers.append('Content-Type', 'application/json');
headers = headers.append('x-corralation-id', '12345');

and boom!
enter image description here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)