When working with angular 8
, I encountered an issue while trying to save an excel file. The error message displayed was as follows:
ERROR TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.
at Function.a [as saveAs] (FileSaver.min.js:1:1339)
at SafeSubscriber._next (zdeliverysys.component.ts:225:23)
I attempted the following steps to resolve the issue:
component ts
this._dataService.PostUpload(this.fileToUpload)
.subscribe(blob => {
saveAs(blob.body, this.fileToUpload +'.xlsx');
});
service.ts
PostUpload( file:any):Observable<any>
{
const formData: FormData = new FormData();
formData.append('file', file,file.name);
return this.http.post(this.url + 'Z2Delivery/Upload' , formData,{responseType: 'blob' });
}
Can you suggest a solution to overcome this problem?