我正在尝试应用此解决方案:How to download excel/Zip files in Angular 4 但我有一些错误。
我服务的代码是:
return this.http.post(endpoint,
body,
{headers: new HttpHeaders({'Accept':'application/vnd.ms-excel'}) ,
responseType: ResponseContentType.Blob})
.map(res => res.blob());
但是我收到了这个错误:
Argument of type '{ headers: HttpHeaders; responseType: ResponseContentType.Blob; }' is not assignable to parameter of type '{ headers?: HttpHeaders; observe?: "body"; params?: HttpParams; reportProgress?: boolean; respons...'.
Types of property 'responseType' are incompatible.
Type 'ResponseContentType.Blob' is not assignable to type '"json"'.
我不知道该怎么做:\
答案 0 :(得分:1)
制作responseType:" blob"解决了我的问题!
return this.http.post(endpoint, body, {responseType: "blob"}).map(res => res).catch(this.handleError);