troyanskiy / ngx-resource

Resource (REST) Client for Angular 2
http://troyanskiy.github.io/ngx-resource/
200 stars 46 forks source link

Old deprecated ngx-resource - how to define responseType. #181

Open Puza2010 opened 3 years ago

Puza2010 commented 3 years ago

Hi,

I know that i need to upgrade ngx-resource to the core version. But before i do, can you please tell me how to set responseType to 'blob' in ngx-resource (deprecated version)?

I need something like this using ngx-resource(deprecated version) that I wrote in angular http:

`this.http.get('url', {
          params: myParams,
          headers: new HttpHeaders({
              'Accept': 'text/csv',
              'Content-Type': 'text/csv'
          }),
          responseType: 'blob'
 }).subscribe(data => this.downloadFile(data)`

Thank you in advance!

troyanskiy commented 3 years ago

Hi! In latest version try that

  @ResourceAction({
    method: ResourceRequestMethod.Get,
    pathPrefix: '/files/file/{!id}',
    responseBodyType: ResourceResponseBodyType.Blob
  })
  getFile: IResourceMethodObservable<{id: string}, Blob>;

For the deprecated version I don't really remember, but you can try to dig in the sources.

Puza2010 commented 3 years ago

Hi, thank you for answering!

I did find responseBodyType in core version. But I couldn't find anything like that in deprecated version in the sources :(

Puza2010 commented 3 years ago

@troyanskiy any chance you could look it up? I can't find this.