Kli*_*itz 5 http httpclient ionic-framework angular
我尝试从api下载图像(png).我的问题是,由于某种原因,只有json文件被ionic/angular接受.
return this.http.get(this.authKeys.serverURL, {headers: this.header, responseType: ResponseContentType.Blob});
Run Code Online (Sandbox Code Playgroud)
发生以下错误:
Argument of type '{ headers: any; responseType: ResponseContentType.Blob; }' is not assignable to parameter of type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: Ht...'. Types of property 'responseType' are incompatible. Type 'ResponseContentType.Blob' is not assignable to type '"json"'.
Run Code Online (Sandbox Code Playgroud)
出于某种原因,只允许json类型的响应......
Pan*_*kar 10
responseType持有字符串值.所以你应该传递这些值中的任何一个
'arraybuffer' | 'blob' | 'json' | 'text';
Run Code Online (Sandbox Code Playgroud)
在早期版本的Angular 2中,它的API设计为期望枚举值responseType,请在此处查看
| 归档时间: |
|
| 查看次数: |
3881 次 |
| 最近记录: |