2

我正在尝试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 图像吗?

4

0 回答 0