0

I am trying to apply this solution: How to download excel/Zip files in Angular 4 But I am having some errors.

The code on my service is this:

    return this.http.post(endpoint, 
                          body, 
                         {headers: new HttpHeaders({'Accept':'application/vnd.ms-excel'}) , 
                          responseType: ResponseContentType.Blob})
                     .map(res => res.blob());

But I am getting this error:

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"'.

I have no idea what to do about it :\

1 Answer 1

1

Making responseType:"blob" solved my issue!

return this.http.post(endpoint, body, {responseType: "blob"}).map(res => res).catch(this.handleError);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.