0

I saw on forums that the error can be caused by the "type", could anyone give me any tips?

Service

getDownloadZip(): Observable<any>  {
    const url = `${this._URL_SERVICE}/result`;
    return this.http.get<Array<any>>(url, this.httpOptions).pipe(retry(1), catchError(this.handleError));
  }

TS

  downloadZip() {
    this.servicosApiService
      .getServicosCSV()
      .subscribe((res: any) => {
        const file = new Blob([res], {
          type: res.type
        });
        console.log(file);
        const blob = window.URL.createObjectURL(file);
        const link = document.createElement('a');
        link.href = blob;
        link.download = 'report.zip'
        link.click();
        window.URL.revokeObjectURL(blob);
        link.remove();
    })
  }

Error

ERROR Error code: 200, message: Http failure during parsing for http://localhost/api/v1/result

João
  • 31
  • 6
  • Can you share the `httpOptions` that you pass to the HttpClient? – Philipp Meissner Jul 01 '22 at 18:32
  • Does this answer your question? [Http failure during parsing for http... while downloading pdf file](https://stackoverflow.com/questions/50018730/http-failure-during-parsing-for-http-while-downloading-pdf-file) – Philipp Meissner Jul 01 '22 at 18:33

0 Answers0