<分区>
我正在使用 angular 5,这是我从服务器下载文件的代码:
1- 服务:
export(url) {
return this.http.get(url, {responseType: 'blob'});
2-组件代码:
public downloadfile(file: any) {
var resp: any;
this.documentsService.export('http://localhost:55650/api/files/attachment/' + file.docf_GUID)
.subscribe(
(data) =>{
resp = data, saveAs(resp), console.log(resp.headers) },
() => { }
);
}
但是当我尝试获取响应 header 时出现此错误:
error TS2339: Property 'headers' does not exist on type 'Blob'.