The Angular docs say:
The response body doesn\'t return all the data you may need. Sometimes servers return special headers or status codes to indic
The way I got around this, without inline-ing the options (which can lead to code that's not as clean) was to create an interface for the request options. Code looks like this :
export interface IRequestOptions {
body?: any;
headers?: HttpHeaders | { [header: string]: string | Array };
observe?: any;
params?: HttpParams | { [param: string]: string | Array };
reportProgress?: boolean;
responseType?: "arraybuffer" | "blob" | "json" | "text";
withCredentials?: boolean;
}
Then this is used as such :
const options: IRequestOptions = {
headers: new HttpHeaders({"Content-Type": "application/json"}),
observe: "response"
};
return this.httpClient.post(`${environment.USER_SERVICE_BASE_URL}`,
{"username": credentials.username, "password": credentials.password}, options)
.pipe(
map((res: HttpResponse) => ...
);
Change for original post to use lettable or pipeable (whatever the current name is today) operators