Error: "headers" option needs to be an dictionary style

807 views Asked by At

I am trying to get a blob image from the backend and I am using native HTTP in the ionic 4 app.

Implementation as shown below:

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) })
    )
  }

I need these headers

the sendRequest() allows me to pass the responseType parameter. I also tried using get() but I whenever I make the request call, I am getting this error:

Error Message

I am missing something with headers or do I need to send a responseType in another way to get the blob image?

0

There are 0 answers