Skip to content

Commit

Permalink
fix: add correct responseType for pdf download
Browse files Browse the repository at this point in the history
  • Loading branch information
co-sic committed Sep 9, 2021
1 parent 1e3b5c4 commit c692c7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/base/Requestable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { AxiosResponse } from 'axios';
import axios, { AxiosResponse, ResponseType } from 'axios';
import Bottleneck from 'bottleneck';
import { log } from '../logger';
import { EasybillError } from './EasybillError';
Expand Down Expand Up @@ -55,8 +55,9 @@ export class Requestable {
params?: Record<string, unknown>;
data?: Record<string, unknown>;
headers?: Record<string, unknown>;
responseType?: ResponseType;
}): Promise<T> {
const { method, url, params, data, headers } = config;
const { method, url, params, data, headers, responseType } = config;

return limiter.schedule(async () => {
try {
Expand All @@ -67,9 +68,10 @@ export class Requestable {
params,
headers,
cancelToken: this.axiosCancelTokenSource.token,
responseType,
});
return res.data;
} catch (error) {
} catch (error: any) {
// The request was made and the server responded with a status code
if (error.response) {
log({
Expand Down
1 change: 1 addition & 0 deletions src/document/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class DocumentAPI extends Requestable {
headers: {
accept: 'application/pdf',
},
responseType: 'arraybuffer',
});
}
}

0 comments on commit c692c7f

Please sign in to comment.