[英]Download CSV through REST Api
我必須從 REST Api 下載 CSV。 我正在做 Http 通過我的服務獲取請求
用戶服務.ts
public downloadCsv(target: string): Observable<any> {
return this.http.get<any>(
this.api.getUrl(environment.api.endpoints.download).replace('{target}', target)
).pipe(
catchError(this.api.handleError)
);
}
並在我的組件中訂閱 observable
客戶列表.component.ts
downloadCsv() {
this.userService.downloadCsv('users_ub').subscribe(
(response) => {
}
);
}
我收到一個錯誤
VM73806 vendor.js:56089 ERROR Error Code: 200
Message: Http failure during parsing for http://localhost:90/api/download/csv/users_ub.csv
從我的 api 文檔請求數據
使用{ responseType: 'blob' }
this.http.get<any>(url,{ responseType: 'blob' })
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.