Set HTTP responseType as arraybuffer

I facing an error while building a jhipster project that says that I need to change the parameter responseType in a get request.

Here's the error:

Argument of type '{ responseType: "arraybuffer"; }' is not assignable to parameter of type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: Ht...'. Types of property 'responseType' are incompatible. Type '"arraybuffer"' is not assignable to type '"json"'. Version: typescript 2.7.2

As you see typescript is telling me to change the value from arraybuffer to json, but I need to keep it as arraybuffer since I am dealing with a file and I fully aware that the responseType can be set to arraybuffer, blob, json or text.

Here's the code

showfile(file?: any): Observable<any> {
    return this.http.get<any>(SERVER_API_URL + `leave/api/downloadFile/${file}`, { responseType: 'arraybuffer' });



Remove the any


When I need to call an endpoint that is returning a file, I usually use the type Observable<HttpResponse<Blob>>.


showfile(file?: any): Observable<HttpResponse<Blob>> {
    return this.http.get(SERVER_API_URL + `leave/api/downloadFile/${file}`, { responseType: 'blob' });


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.