我正在尝试blob
从后端获取图像,并native HTTP
在 ionic 4 应用程序中使用。
实现如下图:
import { HTTP } from '@ionic-native/http/ngx';
constructor(private nativeHttp: HTTP) {}
getAttachmentWithNativeHttp(url: string, parameters?: any): Observable<any> {
url = url + this.commonService.getQueryString(parameters);
var headers = this.getHeaders('GET', url);
this.nativeHttp.clearCookies();
this.nativeHttp.setServerTrustMode('nocheck');
const reqOptions: any = {
method: 'get',
responseType: 'blob' as 'blob',
headers: headers
}
return from(this.nativeHttp.sendRequest(url, reqOptions)).pipe(
finalize(() => { if (toIntercept) this.setProgressDialogVisibility(false) })
)
}
允许sendRequest()
我传递responseType
参数。我也尝试过使用get()
,但每当我发出请求调用时,我都会收到此错误:
我遗漏了一些东西,headers
或者我需要以responseType
另一种方式发送一个来获取 blob 图像吗?