Angular HttpClient: Return both Blob and response Headers
export interface BlobAndHeaders {
blob: Blob;
headers: Headers;
}
myApi(arg: string): Observable<BlobAndHeaders> {
return this.http.get<BlobAndHeaders>(`${this.baseURL}/api/myapi`, {
observe: 'response',
responseType: 'blob' as 'json',
params: {arg: arg},
}).pipe(map(
response => {
if(response.body === null) {
throw new Error('No data received');
}
return {"blob": response.body, "headers": response.headers};
}
));
}