/* For Download Excel Bulk Upload */
getDownloadExcelForBulkUpload() {
return this.commonApi.getDownloadExcelForBulkUpload();
}
getDownloadExcelForBulkUpload() {
return this.getBlob(`${environment.baseUrl + ApiUrls.DownloadExcelForBulkUpload}`);
}
GenericApi API File
protected getBlob(url: string, options: any = {}): Observable<Blob> {
return this.http.get<Blob>(url, { ...options });
}
ApiUrls File:-
DownloadExcelForBulkUpload: '/api/files/bulkUpload/ServiceDownload',
But I am gettint this error on GenericApi API File: -
Type 'Observable<HttpEvent<Blob>>' is not assignable to type 'Observable<Blob>'.
Type 'HttpEvent<Blob>' is not assignable to type 'Blob'.
Type 'HttpSentEvent' is missing the following properties from type 'Blob': size, arrayBuffer, bytes, slice, and 2 more.ts(2322)
错误消息中的原因很明显
type“可观察到”不可分割为类型 “可观察”。 类型“ httpevent”不能分配给类型 'blob'.
HttpClient.get
默认情况下返回
protected getBlob(url: string, options: any = {}): Observable<Blob> {
return this.http.get<Blob>(url, { responseType: 'blob' as 'json', ...options });
}
用于打字稿类型检查
as json