我有一个向我的后端发出 http 调用的服务:
exportSubs(param: Param): Observable<Sub[]> {
return this.http.get<Sub[]>(
`${environment.apiBaseUrl}/blah`,
{headers: this.httpUtil.getReqHeaders})
.catch(error => this.httpUtil.handleError(error));
}
Run Code Online (Sandbox Code Playgroud)
我在哪里设置 responseType?
您可以使用responseType. 请参阅请求非 JSON 数据
在您的示例中,您应该能够使用:
return this.http.get(
`${environment.apiBaseUrl}/blah`, { responseType: 'text' })
Run Code Online (Sandbox Code Playgroud)
编辑
您可以将 responseType 设置为 blob,
return this.http.get(`${environment.apiBaseUrl}/blah`, { responseType: 'blob' });
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7876 次 |
| 最近记录: |