【问题标题】:Fetch binary data (xls, pdfs, csvs) with angular 4使用角度 4 获取二进制数据(xls、pdfs、csvs)
【发布时间】:2017-10-22 15:34:33
【问题描述】:

我正在尝试应用此解决方案: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"'.

我不知道该怎么办:\

【问题讨论】:

    标签: angular


    【解决方案1】:

    制作 responseType:"blob" 解决了我的问题!

    return this.http.post(endpoint, body, {responseType: "blob"}).map(res => res).catch(this.handleError);
    

    【讨论】:

      猜你喜欢
      • 2011-07-19
      • 1970-01-01
      • 2018-03-28
      • 1970-01-01
      • 1970-01-01
      • 2019-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多