I'd like to make an observable like this in (angular 5).
How can I declare responseType in Angular 6?
The Angular 5 code:
public ExportSomeThing(
ano: number
): Observable<IDownloadArquivo> {
let q = this.http
.get(this.apiUrl + ano + '/pordia/excel', {
responseType: ResponseContentType.Blob // <<<-- This code
}).map((res) => {
My angular 6 code:
public MyExport(
ano: number
): Observable<IXpto> {
let q = this.http
.get( this.api_rul + ano + '/some_path/', {
responseType: "ResponseContentType.Blob" // <<<--- error here !!!
}).map((res) => {
The error is:
[ts]
Argument of type '{ responseType: "ResponseContentType.Blob"; }' is not assignable to parameter of type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }'.
Types of property 'responseType' are incompatible.
Type '"ResponseContentType.Blob"' is not assignable to type '"json"'.
How can I make my http.get similar in Angular 6?
I'm trying to download Excel method!
responseType: 'blob'is enough. Be careful not to use generic parameter for the get/post method call, since now the return type is obvious no generic parameter is needed. anyone who came here see: angular.io/guide/http#requesting-non-json-data